|
@@ -5,6 +5,9 @@ from Database.sqlsettings import SQLSettings as sqlsettings
|
5
|
5
|
from django.conf import settings
|
6
|
6
|
import re
|
7
|
7
|
|
|
8
|
+import logging as logger #TODO hack to replace the standarts use of logging in django
|
|
9
|
+logger.getLogger().setLevel('DEBUG')
|
|
10
|
+
|
8
|
11
|
class SqlWrapper(object):
|
9
|
12
|
|
10
|
13
|
def __init__(self):
|
|
@@ -155,8 +158,9 @@ class SqlWrapper(object):
|
155
|
158
|
try:
|
156
|
159
|
table.create(self.get_write_engine())
|
157
|
160
|
return True
|
158
|
|
- except:
|
|
161
|
+ except Exception as e:
|
159
|
162
|
# TODO Ajuster le code d'erreur à retourner
|
|
163
|
+ logger.warning("Error creating table : "+str(e))
|
160
|
164
|
return False
|
161
|
165
|
|
162
|
166
|
|
|
@@ -187,8 +191,9 @@ class SqlWrapper(object):
|
187
|
191
|
table.drop(db, checkfirst=True)
|
188
|
192
|
db.close()
|
189
|
193
|
return True
|
190
|
|
- except:
|
|
194
|
+ except Exception as e:
|
191
|
195
|
# TODO ajuster le code d'erreur
|
|
196
|
+ logger.warning("Error droping table : "+str(e))
|
192
|
197
|
return False
|
193
|
198
|
|
194
|
199
|
|
|
@@ -277,8 +282,9 @@ class SqlWrapper(object):
|
277
|
282
|
sqlresult = self.execute(update_object, sqlsettings.ACTION_TYPE_WRITE)
|
278
|
283
|
updated_lines_count = sqlresult.rowcount
|
279
|
284
|
|
280
|
|
- except DataError:
|
|
285
|
+ except DataError as e:
|
281
|
286
|
# TODO Voir si on garde "-1" ou si on place un "None" ou un "False"
|
|
287
|
+ logger.warning("Error updating database : "+str(e))
|
282
|
288
|
updated_lines_count = -1
|
283
|
289
|
|
284
|
290
|
return updated_lines_count
|
|
@@ -369,7 +375,8 @@ class SqlWrapper(object):
|
369
|
375
|
records = sqlresult.fetchall()
|
370
|
376
|
for record in records:
|
371
|
377
|
selected_lines.append(dict(zip(record.keys(), record)))
|
372
|
|
- except:
|
|
378
|
+ except Exception as e:
|
|
379
|
+ logger.debug("Error selecting in database : "+str(e))
|
373
|
380
|
selected_lines = None
|
374
|
381
|
|
375
|
382
|
return selected_lines
|