Project

General

Profile

« Previous | Next » 

Revision 3240

sql.py: DbConn.run_query(): Added profiling of query execution, which is logged with the query

View differences:

lib/sql.py
354 354
        if not self.caching: cacheable = False
355 355
        used_cache = False
356 356
        
357
        start_time = time.time()
357 358
        try:
358 359
            # Get cursor
359 360
            if cacheable:
......
369 370
                raise
370 371
            else: self.do_autocommit()
371 372
        finally:
373
            time_ = time.time() - start_time
372 374
            self.print_notices()
373 375
            if self.debug: # log or return query
374 376
                query = str(get_cur_query(cur, query))
......
376 378
                # put on a separate line when viewed in a text editor.
377 379
                query = query.replace('\t', '\r', 1)
378 380
                
379
                if used_cache: cache_status = 'cache hit'
380
                elif cacheable: cache_status = 'cache miss'
381
                else: cache_status = 'non-cacheable'
381
                msg = 'DB query: '
382 382
                
383
                msg = 'DB query: '+cache_status+':\n'+strings.as_code(query,
384
                    'SQL')
383
                if used_cache: msg += 'cache hit'
384
                elif cacheable: msg += 'cache miss'
385
                else: msg += 'non-cacheable'
385 386
                
387
                msg += ', took '+str(time_)+'s:\n'+strings.as_code(query, 'SQL')
388
                
386 389
                if debug_msg_ref != None: debug_msg_ref[0] = msg
387 390
                else: self.log_debug(msg, log_level)
388 391
        

Also available in: Unified diff