def setUp(self): self.db = database( 'mysql', host='database', user='******', passwd='password', db='test' )
def setUp(self): params = dict( host='database', user='******', passwd='password', db='test', ) self.db = database('mysql', **params) self.create_tables(self.db) self.people = self.get_record_store() self.joe_id = self.people.put(Person(name='Joe', age=50)) self.sam_id = self.people.put(Person(name='Sam', age=25)) self.people.put(Person(name='Ann', age=30))
def setup_test(): """set up test database""" # pylint: disable=invalid-name def create_test_tables(db): """create test tables""" db(""" create table if not exists person ( id int not null auto_increment, name varchar(100), age smallint, kids smallint, birthdate date, PRIMARY KEY (id) ) """) db(""" create table if not exists account ( account_id int not null auto_increment, name varchar(100), added date, PRIMARY KEY (account_id) ) """) def delete_test_tables(db): """drop test tables""" db('drop table if exists person') db('drop table if exists account') from zoom.db import database db = database( 'mysql', host='database', db='test', user='******', passwd='password' ) delete_test_tables(db) create_test_tables(db) return db
parser = argparse.ArgumentParser() parser.add_argument("--backup", help="backup dz_users to dz_users_b", default=False, action="store_true") parser.add_argument("--reset", help="push the dz_users_b data back into dz_users", default=False, action="store_true") parser.add_argument("--alter", help="alter the password field length for dz_users", default=False, action="store_true") parser.add_argument("--checks", help="run the pre-hash integrity checks", default=False, action="store_true") parser.add_argument("--hash", help="perform the bcrypt hash on the database", default=False, action="store_true") parser.add_argument("--do", help="perform the backup, alter password hash field width and hash the weak hashes, all for the given database", default=False, action="store_true") parser.add_argument("--database", help="database to perform the operations against", default='zoomdata', action="store") parser.add_argument("--user", help="database user to use", default='zoom', action="store") parser.add_argument("--pwd", help="database user password to use", default='zoom', action="store") args = parser.parse_args() db = database( host='localhost', db=args.database, user=args.user, passwd=args.pwd, charset='utf8' ) if args.backup: backup() if args.reset: reset() if args.alter: alter() if args.checks: pre_integrity_checks() if args.hash: pre_integrity_checks() rehash_db()