aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/dawn_utils.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/python/dawn_utils.py b/python/dawn_utils.py
index b2c7ae49..cd7396e1 100644
--- a/python/dawn_utils.py
+++ b/python/dawn_utils.py
@@ -1,5 +1,5 @@
from sqlalchemy.sql import text
-from sqlalchemy import create_engine, MetaData
+from sqlalchemy import create_engine
import os
def create_trigger_function(conn):
@@ -31,30 +31,26 @@ identifier = COALESCE(identifier, cusip, isin)', NEW.id);
$$ language plpgsql""")
conn.execute(auto_dealid)
-def create_triggers(schema = None):
+def create_triggers():
trigger = db.DDL("""CREATE TRIGGER dealid
AFTER INSERT ON %(fullname)s
FOR EACH ROW
- EXECUTE PROCEDURE %(schema)s.auto_dealid()""")
+ EXECUTE PROCEDURE auto_dealid()""")
for name, tb in db.metadata.tables.items():
- if schema is not None:
- tb.schema = schema
db.event.listen(tb, 'after_create', trigger)
if __name__ == "__main__":
""" This script will create the tables and triggers for the Dawn app.
If schema is not None, it will create it under a specific schema"""
- engine = create_engine('postgresql://dawn_user@debian/dawndb')
+ engine = create_engine('postgresql://qa@debian/dawndb')
conn = engine.connect()
schema = 'qa'
- conn.execute("CREATE SCHEMA IF NOT EXISTS {}".format(schema))
+ #conn.execute("CREATE SCHEMA IF NOT EXISTS {}".format(schema))
conn.execute("SET search_path TO %s", (schema,))
create_trigger_function(conn)
conn.close()
os.environ['CONF'] = 'config.ini'
- from Dawn import db, app
- db.init_app(app)
- with app.app_context():
- create_triggers('qa')
- db.create_all()
+ from Dawn import db
+ create_triggers()
+ db.create_all()