Revision 3239
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
354 | 354 |
if not self.caching: cacheable = False |
355 | 355 |
used_cache = False |
356 | 356 |
|
357 |
def log_msg(query): |
|
358 |
if used_cache: cache_status = 'cache hit' |
|
359 |
elif cacheable: cache_status = 'cache miss' |
|
360 |
else: cache_status = 'non-cacheable' |
|
361 |
|
|
362 |
# So that the src comment is hidden when cating the file, and put |
|
363 |
# on a separate line when viewed in a text editor. |
|
364 |
query = query.replace('\t', '\r', 1) |
|
365 |
|
|
366 |
return 'DB query: '+cache_status+':\n'+strings.as_code(query, 'SQL') |
|
367 |
|
|
368 | 357 |
try: |
369 | 358 |
# Get cursor |
370 | 359 |
if cacheable: |
... | ... | |
382 | 371 |
finally: |
383 | 372 |
self.print_notices() |
384 | 373 |
if self.debug: # log or return query |
385 |
msg = log_msg(str(get_cur_query(cur, query))) |
|
374 |
query = str(get_cur_query(cur, query)) |
|
375 |
# So that the src comment is hidden when cating the file, and |
|
376 |
# put on a separate line when viewed in a text editor. |
|
377 |
query = query.replace('\t', '\r', 1) |
|
378 |
|
|
379 |
if used_cache: cache_status = 'cache hit' |
|
380 |
elif cacheable: cache_status = 'cache miss' |
|
381 |
else: cache_status = 'non-cacheable' |
|
382 |
|
|
383 |
msg = 'DB query: '+cache_status+':\n'+strings.as_code(query, |
|
384 |
'SQL') |
|
385 |
|
|
386 | 386 |
if debug_msg_ref != None: debug_msg_ref[0] = msg |
387 | 387 |
else: self.log_debug(msg, log_level) |
388 | 388 |
|
Also available in: Unified diff
sql.py: DbConn.run_query(): Move log_msg() to where it's used, so that it runs after the query is run and can refer to profiling variables