aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/sql/open.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/db/sql/open.py')
-rw-r--r--mediagoblin/db/sql/open.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/mediagoblin/db/sql/open.py b/mediagoblin/db/sql/open.py
new file mode 100644
index 00000000..c682bd3b
--- /dev/null
+++ b/mediagoblin/db/sql/open.py
@@ -0,0 +1,33 @@
+from sqlalchemy import create_engine
+
+from mediagoblin.db.sql.base import Session
+from mediagoblin.db.sql.models import Base
+
+
+class DatabaseMaster(object):
+ def __init__(self, engine):
+ self.engine = engine
+
+ for k,v in Base._decl_class_registry.iteritems():
+ setattr(self, k, v)
+
+ def commit(self):
+ Session.commit()
+
+ def save(self, obj):
+ Session.add(obj)
+ Session.flush()
+
+ def reset_after_request(self):
+ Session.remove()
+
+
+def setup_connection_and_db_from_config(app_config):
+ engine = create_engine(app_config['sql_engine'], echo=True)
+ Session.configure(bind=engine)
+
+ return "dummy conn", DatabaseMaster(engine)
+
+
+def check_db_migrations_current(db):
+ pass