Revision 2441
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): |
|
276 |
def run_query(self, query, params=None, cacheable=False, log_level=2):
|
|
277 | 277 |
'''Translates known DB errors to typed exceptions: |
278 | 278 |
See self.DbCursor.execute().''' |
279 | 279 |
assert query != None |
... | ... | |
297 | 297 |
if used_cache: cache_status = 'Cache hit' |
298 | 298 |
elif cacheable: cache_status = 'Cache miss' |
299 | 299 |
else: cache_status = 'Non-cacheable' |
300 |
self.log_debug(cache_status+': ' |
|
301 |
+strings.one_line(str(get_cur_query(cur, query, params))))
|
|
300 |
self.log_debug(cache_status+': '+strings.one_line(
|
|
301 |
str(get_cur_query(cur, query, params))), log_level)
|
|
302 | 302 |
|
303 | 303 |
return cur |
304 | 304 |
|
... | ... | |
347 | 347 |
|
348 | 348 |
def with_savepoint(db, func): return db.with_savepoint(func) |
349 | 349 |
|
350 |
def run_query(db, query, params=None, recover=None, cacheable=False): |
|
350 |
def run_query(db, query, params=None, recover=None, cacheable=False, **kw_args): |
|
351 |
'''For params, see run_raw_query()''' |
|
351 | 352 |
if recover == None: recover = False |
352 | 353 |
|
353 | 354 |
try: |
354 |
def run(): return run_raw_query(db, query, params, cacheable) |
|
355 |
def run(): return run_raw_query(db, query, params, cacheable, **kw_args)
|
|
355 | 356 |
if recover and not db.is_cached(query, params): |
356 | 357 |
return with_savepoint(db, run) |
357 | 358 |
else: return run() # don't need savepoint if cached |
Also available in: Unified diff
sql.py: DbConn.run_query(): Added log_level param and pass it to self.log_debug(). run_query(): Pass extra kw_args to DbConn.run_query() (via run_raw_query()) so that caller can specify log_level.