longqueries.py
changeset 2 efee419b7a2d
child 5 57cf8fdff5ed
equal deleted inserted replaced
0:eaae9539e910 2:efee419b7a2d
       
     1 #!/usr/bin/env python3.2
       
     2 
       
     3 from pgtools import pgstats
       
     4 from toolbase import ToolBase
       
     5 
       
     6 
       
     7 class LongQueriesTool(ToolBase):
       
     8     def __init__(self):
       
     9         ToolBase.__init__(self, name='longqueries', desc='Lis long queries.')
       
    10         self.init()
       
    11 
       
    12     def main(self):
       
    13         stats = pgstats.PgStats(self.pgm.get_conn('target'))
       
    14 
       
    15         for ln in stats.list_long_queries():
       
    16             print(ln['query'])
       
    17             print('   ', 'query_start:', ln['query_start'].strftime('%F %T'))
       
    18 
       
    19 
       
    20 tool = LongQueriesTool()
       
    21 tool.main()
       
    22