|
@@ -1,7 +1,7 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
|
3
|
3
|
from sqlalchemy import * # TODO ajuster les classes à importer
|
4
|
|
-from sql_settings import SqlSettings as sqlsettings
|
|
4
|
+from Database.sqlsettings import SQLSettings as sqlsettings
|
5
|
5
|
from django.conf import settings
|
6
|
6
|
import re
|
7
|
7
|
|
|
@@ -33,13 +33,13 @@ class SqlWrapper(object):
|
33
|
33
|
driver = sqlsettings.dbms_list[dialect]['driver']
|
34
|
34
|
username = connection_params['USER']
|
35
|
35
|
password = connection_params['PASSWORD']
|
36
|
|
- hostname = connection_params['HOST'] if connection_params['HOST']!='' else sqlsettings.DEFAULT_HOSTNAME
|
37
|
|
- port = connection_params['PORT']
|
|
36
|
+ hostname = connection_params['HOST'] if 'HOST' in connection_params else sqlsettings.DEFAULT_HOSTNAME
|
|
37
|
+ port = connection_params['PORT'] if 'PORT' in connection_params else ''
|
38
|
38
|
host = hostname if port=='' else '%s:%s' % (hostname, port)
|
39
|
39
|
database = connection_params['NAME']
|
40
|
40
|
|
41
|
41
|
connection_string = '%s+%s://%s:%s@%s/%s' % (dialect, driver, username, password, host, database)
|
42
|
|
- engine = create_engine(connection_string, encoding=sqlsettings.dbms_list[dialect]['encoding'], echo=True, poolclass=NullPool)
|
|
42
|
+ engine = create_engine(connection_string, encoding=sqlsettings.dbms_list[dialect]['encoding'], echo=True)
|
43
|
43
|
return engine
|
44
|
44
|
|
45
|
45
|
def get_read_engine(self):
|
|
@@ -130,7 +130,7 @@ class SqlWrapper(object):
|
130
|
130
|
elif column_type=='BOOLEAN':
|
131
|
131
|
column = Column(column_name, BOOLEAN)
|
132
|
132
|
|
133
|
|
- if column and column_extra:
|
|
133
|
+ if column is not None and column_extra:
|
134
|
134
|
if 'nullable' in column_extra:
|
135
|
135
|
column.nullable = column_extra['nullable']
|
136
|
136
|
if 'primarykey' in column_extra:
|