Revision 2445
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
273 | 273 |
|
274 | 274 |
def esc_name(self, name): return esc_name(self, name) # calls global func |
275 | 275 |
|
276 |
def run_query(self, query, params=None, cacheable=False, log_level=2): |
|
276 |
def run_query(self, query, params=None, cacheable=False, log_level=2, |
|
277 |
exc_log_level=None): |
|
278 |
''' |
|
279 |
@param exc_log_level The log_level if the query throws an exception. |
|
280 |
Defaults to the value of log_level. |
|
281 |
''' |
|
277 | 282 |
assert query != None |
283 |
if exc_log_level == None: exc_log_level = log_level |
|
278 | 284 |
|
279 | 285 |
if not self.caching: cacheable = False |
280 | 286 |
used_cache = False |
287 |
success = False |
|
281 | 288 |
try: |
282 | 289 |
# Get cursor |
283 | 290 |
if cacheable: |
... | ... | |
290 | 297 |
|
291 | 298 |
# Run query |
292 | 299 |
cur.execute(query, params) |
300 |
|
|
301 |
success = True |
|
293 | 302 |
finally: |
294 | 303 |
if self.debug: # only compute msg if needed |
304 |
if not success: log_level = exc_log_level |
|
295 | 305 |
if used_cache: cache_status = 'Cache hit' |
296 | 306 |
elif cacheable: cache_status = 'Cache miss' |
297 | 307 |
else: cache_status = 'Non-cacheable' |
Also available in: Unified diff
sql.py: DbConn.run_query(): Added exc_log_level param to specify a different log_level if the query throws an exception. This will useful for functions that version created tables, functions, etc. if they already exist.