|
@@ -35,8 +35,7 @@ class SqlWrapper(object):
|
35
|
35
|
@param alchemy_logs bool: If true activate sqlalchemy logger
|
36
|
36
|
"""
|
37
|
37
|
|
38
|
|
- if (alchemy_logs != None and \
|
39
|
|
- bool(alchemy_logs) != self.__class__.sqla_logging):
|
|
38
|
+ if (alchemy_logs != None and bool(alchemy_logs) != self.__class__.sqla_logging):
|
40
|
39
|
#logging config changed for sqlalchemy
|
41
|
40
|
self.__class__.restart()
|
42
|
41
|
|
|
@@ -94,8 +93,7 @@ class SqlWrapper(object):
|
94
|
93
|
"""
|
95
|
94
|
c.checkConf()
|
96
|
95
|
if c.started():
|
97
|
|
- logger.warning('Starting SqlWrapper but it is allready \
|
98
|
|
-started')
|
|
96
|
+ logger.warning('Starting SqlWrapper but it is allready started')
|
99
|
97
|
return False
|
100
|
98
|
|
101
|
99
|
c.rengine = c._getEngine(read=True, sqlalogging=None)
|
|
@@ -127,8 +125,7 @@ started')
|
127
|
125
|
dbconf = connconf if connconf in c.config['db'] else 'default'
|
128
|
126
|
|
129
|
127
|
if dbconf not in c.config['db']: #This check should not be here
|
130
|
|
- raise NameError('Configuration error no db "'+dbconf+'" in \
|
131
|
|
-configuration files')
|
|
128
|
+ raise NameError('Configuration error no db "'+dbconf+'" in configuration files')
|
132
|
129
|
|
133
|
130
|
cfg = c.config['db'][dbconf] #Database config
|
134
|
131
|
|
|
@@ -146,8 +143,7 @@ configuration files')
|
146
|
143
|
user += (':'+cfg['PASSWORD'] if 'PASSWORD' in cfg else '')
|
147
|
144
|
|
148
|
145
|
if 'HOST' not in cfg:
|
149
|
|
- logger.info('Not HOST in configuration, using \
|
150
|
|
-localhost')
|
|
146
|
+ logger.info('Not HOST in configuration, using localhost')
|
151
|
147
|
host = 'localhost'
|
152
|
148
|
else:
|
153
|
149
|
host = cfg['HOST']
|
|
@@ -157,8 +153,7 @@ localhost')
|
157
|
153
|
conn_str = '%s+%s://'%(cfg['ENGINE'], edata['driver'])
|
158
|
154
|
conn_str += '%s@%s/%s'%(user,host,cfg['NAME'])
|
159
|
155
|
|
160
|
|
- return sqla.create_engine( conn_str, encoding=edata['encoding'],
|
161
|
|
- echo=c._sqllog(sqlalogging))
|
|
156
|
+ return sqla.create_engine(conn_str, encoding=edata['encoding'], echo=c._sqllog(sqlalogging))
|
162
|
157
|
|
163
|
158
|
@classmethod
|
164
|
159
|
def checkConf(c):
|
|
@@ -182,19 +177,16 @@ localhost')
|
182
|
177
|
else:
|
183
|
178
|
if 'default' not in c.config['db']:
|
184
|
179
|
if 'dbread' not in c.config:
|
185
|
|
- err.append('Missing "dbread" in configuration and\
|
186
|
|
- no "default" db declared')
|
|
180
|
+ err.append('Missing "dbread" in configuration and no "default" db declared')
|
187
|
181
|
if 'dbwrite' not in c.config:
|
188
|
|
- err.append('Missing "dbwrite" in configuration and\
|
189
|
|
- no "default" db declared')
|
|
182
|
+ err.append('Missing "dbwrite" in configuration and no "default" db declared')
|
190
|
183
|
for dbname in c.config['db']:
|
191
|
184
|
db = c.config['db'][dbname]
|
192
|
185
|
if 'ENGINE' not in db:
|
193
|
186
|
err.append('Missing "ENGINE" in database "'+db+'"')
|
194
|
187
|
else:
|
195
|
188
|
if db['ENGINE'] != 'sqlite' and 'USER' not in db:
|
196
|
|
- err.append('Missing "USER" in database "\
|
197
|
|
-'+db+'"')
|
|
189
|
+ err.append('Missing "USER" in database "'+db+'"')
|
198
|
190
|
if 'NAME' not in db:
|
199
|
191
|
err.append('Missing "NAME" in database "'+db+'"')
|
200
|
192
|
|
|
@@ -203,18 +195,15 @@ localhost')
|
203
|
195
|
for ename in c.config['engines']:
|
204
|
196
|
engine = c.config['engines'][ename]
|
205
|
197
|
if 'driver' not in engine:
|
206
|
|
- err.append('Missing "driver" in database engine "\
|
207
|
|
-'+ename+'"')
|
|
198
|
+ err.append('Missing "driver" in database engine "'+ename+'"')
|
208
|
199
|
if 'encoding' not in engine:
|
209
|
|
- err.append('Missing "encoding" in database engine "\
|
210
|
|
-'+ename+'"')
|
|
200
|
+ err.append('Missing "encoding" in database engine "'+ename+'"')
|
211
|
201
|
|
212
|
202
|
if len(err)>0:
|
213
|
203
|
err_str = "\n"
|
214
|
204
|
for e in err:
|
215
|
205
|
err_str += "\t\t"+e+"\n"
|
216
|
|
- raise NameError('Configuration errors in LODEL2SQLWRAPPER\
|
217
|
|
-:'+err_str)
|
|
206
|
+ raise NameError('Configuration errors in LODEL2SQLWRAPPER:'+err_str)
|
218
|
207
|
|
219
|
208
|
|
220
|
209
|
@property
|