aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/db.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/python/db.py b/python/db.py
index ec72b053..3c937ba1 100644
--- a/python/db.py
+++ b/python/db.py
@@ -1,9 +1,11 @@
import datetime
+import os
import psycopg2
from psycopg2.extras import DictCursor
from psycopg2 import IntegrityError
from psycopg2.extensions import register_adapter
from sqlalchemy import create_engine
+from sqlalchemy.engine.url import URL
import numpy as np
class InfDateAdapter:
@@ -38,7 +40,12 @@ def nan_to_null(f, _NULL=psycopg2.extensions.AsIs('NULL'),
return _NULL
def dbengine(dbname):
- uri = "postgresql://{0}@debian/{1}".format(dbname[:-2] + '_user',
+ if dbname == 'rmbs_model':
+ uri = URL(drivername="mysql+mysqlconnector",
+ host="debian", database=dbname,
+ query={'option_files': os.path.expanduser('~/.my.cnf')})
+ else:
+ uri = "postgresql://{0}@debian/{1}".format(dbname[:-2] + '_user',
dbname)
return create_engine(uri)