fixes based on ekim's suggestions

pull/77/head
Christopher Usher 5 years ago
parent f75f3e61e8
commit ff5c1f8ecd

@ -14,21 +14,22 @@ from psycogreen.gevent import patch_psycopg
class DBManager(object):
"""Patches psycopg2 before any connections are created, and applies the schema.
Stores connect info for easy creation of new connections, and sets some defaults before
"""Patches psycopg2 before any connections are created. Stores connect info
for easy creation of new connections, and sets some defaults before
returning them.
It has the ability to serve as a primitive connection pool, as getting a new conn will
return existing conns it knows about first, but this mainly just exists to re-use
the initial conn used to apply the schema, and you should use a real conn pool for
any non-trivial use.
It has the ability to serve as a primitive connection pool, as getting a
new conn will return existing conns it knows about first, but this mainly
just exists to re-use the initial conn used to test the connection, and you
should use a real conn pool for any non-trivial use.
Returned conns are set to seralizable isolation level, autocommit, and use NamedTupleCursor cursors.
"""
Returned conns are set to seralizable isolation level, autocommit, and use
NamedTupleCursor cursors."""
def __init__(self, **connect_kwargs):
patch_psycopg()
self.conns = []
self.connect_kwargs = connect_kwargs
# get a connection to test whether connection is working.
conn = self.get_conn()
self.put_conn(conn)

@ -36,19 +36,16 @@ fi
echo "Applying schema for $POSTGRES_DB"
psql -v ON_ERROR_STOP=1 -U $WUBLOADER_USER -d $POSTGRES_DB <<-EOSQL
-- Create type if it doesn't already exist
DO \$\$ BEGIN
CREATE TYPE event_state as ENUM (
CREATE TYPE event_state as ENUM (
'UNEDITED',
'EDITED',
'CLAIMED',
'FINALIZING',
'TRANSCODING',
'DONE'
);
EXCEPTION WHEN duplicate_object THEN
NULL;
END \$\$;
);
CREATE TABLE events (
id UUID PRIMARY KEY,

Loading…
Cancel
Save