def recreate(DATABASE_URL): ''' ''' schema_filename = join(dirname(__file__), 'schema.pgsql') with connect(DATABASE_URL) as conn: with conn.cursor() as db: with open(schema_filename) as file: db.execute(file.read()) db.execute('DROP TABLE IF EXISTS queue') pq = PQ(conn, table='queue') pq.create()
def recreate(DATABASE_URL): ''' ''' schema_filename = join(dirname(__file__), 'schema.pgsql') with connect(DATABASE_URL) as conn: with conn.cursor() as db: with open(schema_filename) as file: db.execute(file.read()) db.execute('DROP TABLE IF EXISTS queue') pq = PQ(conn, table='queue') pq.create()
def recreate(DATABASE_URL): ''' ''' ci_schema_filename = join(dirname(__file__), 'schema.pgsql') cov_schema_filename = join(dirname(__file__), 'coverage', 'schema.pgsql') with connect(DATABASE_URL) as conn: with conn.cursor() as db: db.execute('SET client_min_messages TO WARNING') with open(ci_schema_filename) as file: db.execute(file.read()) with open(cov_schema_filename) as file: db.execute(file.read()) db.execute('DROP TABLE IF EXISTS queue') pq = PQ(conn, table='queue') pq.create()
from psycopg2 import connect, ProgrammingError from pq import PQ from wx_explore.common.config import Config pq = PQ(connect( user=Config.POSTGRES_USER, password=Config.POSTGRES_PASS, host=Config.POSTGRES_HOST, port=Config.POSTGRES_PORT, dbname=Config.POSTGRES_DB, ), table='work_queue') try: pq.create() except ProgrammingError as exc: if exc.pgcode != '42P07': raise