author | Radek Brich <radek.brich@devl.cz> |
Fri, 13 Jan 2012 15:49:24 +0100 | |
changeset 26 | 7f219da7ab71 |
parent 9 | 2fcc8ef0b97d |
child 27 | 5fb4883604d6 |
permissions | -rwxr-xr-x |
2 | 1 |
#!/usr/bin/env python3.2 |
2 |
||
9
2fcc8ef0b97d
Reorganize again :-) Add setup.py.
Radek Brich <radek.brich@devl.cz>
parents:
7
diff
changeset
|
3 |
from pgtoolkit import pgstats, toolbase |
2 | 4 |
|
5 |
||
7
685b20d2d3ab
Reorganize directories. PgDataDiff - reworked. PgManager - add fetchone_adapted, fetchall_adapted to cursor.
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
6 |
class LongQueriesTool(toolbase.SimpleTool): |
2 | 7 |
def __init__(self): |
7
685b20d2d3ab
Reorganize directories. PgDataDiff - reworked. PgManager - add fetchone_adapted, fetchall_adapted to cursor.
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
8 |
toolbase.SimpleTool.__init__(self, name='longqueries', desc='List long queries.') |
2 | 9 |
self.init() |
10 |
||
11 |
def main(self): |
|
12 |
stats = pgstats.PgStats(self.pgm.get_conn('target')) |
|
13 |
||
14 |
for ln in stats.list_long_queries(): |
|
15 |
print(ln['query']) |
|
16 |
print(' ', 'query_start:', ln['query_start'].strftime('%F %T')) |
|
5 | 17 |
print() |
2 | 18 |
|
19 |
||
20 |
tool = LongQueriesTool() |
|
21 |
tool.main() |
|
22 |