def init_postgres(): print("Initializing test database...", file=sys.stderr) dbname = config['database_config']['database'] with psycopg2.connect(dbname='postgres') as conn: conn.autocommit = True with conn.cursor() as cur: cur.execute("DROP DATABASE IF EXISTS {0}".format(dbname)) cur.execute("CREATE DATABASE {0}".format(dbname)) for option, value in DBTest.POSTGRES_OPTS.items(): cur.execute("ALTER DATABASE {0} SET {1} TO '{2}'".format( dbname, option, value)) create_all()
def init_postgres(): print("Initializing test database...", file=sys.stderr) dbname = config['database_config']['database'] with psycopg2.connect(dbname='postgres') as conn: conn.autocommit = True with conn.cursor() as cur: cur.execute("DROP DATABASE IF EXISTS {0}".format(dbname)) cur.execute("CREATE DATABASE {0}".format(dbname)) for option, value in DBTest.POSTGRES_OPTS.items(): cur.execute("ALTER DATABASE {0} SET {1} TO '{2}'".format(dbname, option, value)) create_all()
def execute(self): from alembic.config import Config from alembic import command create_all() alembic_cfg = Config(get_config('alembic.alembic_ini')) command.stamp(alembic_cfg, "head")