Mercurial > sqlpython
comparison mysqlpy.py @ 140:58d15cb69f72
fixed Luca's old queries with new SELECT parsing
author | catherine@Elli.myhome.westell.com |
---|---|
date | Wed, 03 Sep 2008 17:27:28 -0400 |
parents | 4aa28dffe658 |
children | 24b5daa7ebe1 |
comparison
equal
deleted
inserted
replaced
139:0b62e81b068c | 140:58d15cb69f72 |
---|---|
54 self.maxtselctrows = 10 | 54 self.maxtselctrows = 10 |
55 self.query_load10g = ''' | 55 self.query_load10g = ''' |
56 ins.instance_name,ins.host_name,round(os.value,2) load | 56 ins.instance_name,ins.host_name,round(os.value,2) load |
57 from gv$osstat os, gv$instance ins | 57 from gv$osstat os, gv$instance ins |
58 where os.inst_id=ins.inst_id and os.stat_name='LOAD' | 58 where os.inst_id=ins.inst_id and os.stat_name='LOAD' |
59 order by 3 desc; | 59 order by 3 desc |
60 ''' | 60 ''' |
61 self.query_top9i = ''' | 61 self.query_top9i = '''SELECT |
62 sid,username,osuser||'@'||terminal "Server User@terminal",program,taddr, status, | 62 sid,username,osuser||'@'||terminal "Server User@terminal",program,taddr, status, |
63 module, sql_hash_value hash, fixed_table_sequence seq, last_call_et elaps | 63 module, sql_hash_value hash, fixed_table_sequence seq, last_call_et elaps |
64 from v$session | 64 from v$session |
65 where username is not null and program not like 'emagent%' and status='ACTIVE' | 65 where username is not null and program not like 'emagent%' and status='ACTIVE' |
66 and audsid !=sys_context('USERENV','SESSIONID'); | 66 and audsid !=sys_context('USERENV','SESSIONID') ; |
67 ''' | 67 ''' |
68 self.query_ractop = ''' | 68 self.query_ractop = '''SELECT |
69 inst_id||'_'||sid inst_sid,username,osuser||'@'||terminal "User@Term",program, decode(taddr,null,null,'NN') tr, | 69 inst_id||'_'||sid inst_sid,username,osuser||'@'||terminal "User@Term",program, decode(taddr,null,null,'NN') tr, |
70 sql_id, '.'||mod(fixed_table_sequence,1000) seq, state||': '||event event, | 70 sql_id, '.'||mod(fixed_table_sequence,1000) seq, state||': '||event event, |
71 case state when 'WAITING' then seconds_in_wait else wait_time end w_tim, last_call_et elaps | 71 case state when 'WAITING' then seconds_in_wait else wait_time end w_tim, last_call_et elaps |
72 from gv$session | 72 from gv$session |
73 where status='ACTIVE' and username is not null | 73 where status='ACTIVE' and username is not null |
74 and not (event like '% waiting for messages in the queue' and state='WAITING') | 74 and not (event like '% waiting for messages in the queue' and state='WAITING') |
75 and audsid !=sys_context('USERENV','SESSIONID'); | 75 and audsid !=sys_context('USERENV','SESSIONID'); |
76 ''' | 76 ''' |
77 self.query_longops = ''' | 77 self.query_longops = '''SELECT |
78 inst_id,sid,username,time_remaining remaining, elapsed_seconds elapsed, sql_hash_value hash, opname,message | 78 inst_id,sid,username,time_remaining remaining, elapsed_seconds elapsed, sql_hash_value hash, opname,message |
79 from gv$session_longops | 79 from gv$session_longops |
80 where time_remaining>0; | 80 where time_remaining>0; |
81 ''' | 81 ''' |
82 | 82 |
83 def do_new(self, args): | 83 def do_new(self, args): |
84 'tells you about new objects' | 84 'tells you about new objects' |
85 self.do_select('''owner, | 85 self.onecmd('''SELECT owner, |
86 object_name, | 86 object_name, |
87 object_type | 87 object_type |
88 FROM all_objects | 88 FROM all_objects |
89 WHERE created > SYSDATE - 7''') | 89 WHERE created > SYSDATE - 7;''') |
90 def do_top9i(self,args): | 90 def do_top9i(self,args): |
91 '''Runs query_top9i defined above, to display active sessions in Oracle 9i''' | 91 '''Runs query_top9i defined above, to display active sessions in Oracle 9i''' |
92 self.do_select(self.query_top9i) | 92 self.onecmd(self.query_top9i) |
93 | 93 |
94 def do_top(self,args): | 94 def do_top(self,args): |
95 '''Runs query_ractop defined above, to display active sessions in Oracle 10g (and RAC)''' | 95 '''Runs query_ractop defined above, to display active sessions in Oracle 10g (and RAC)''' |
96 self.do_select(self.query_ractop) | 96 self.onecmd(self.query_ractop) |
97 | 97 |
98 def do_longops(self,args): | 98 def do_longops(self,args): |
99 '''Runs query_longops defined above, to display long running operations (full scans, etc)''' | 99 '''Runs query_longops defined above, to display long running operations (full scans, etc)''' |
100 self.do_select(self.query_longops) | 100 self.onecmd(self.query_longops) |
101 | 101 |
102 do_get = Cmd.do__load | |
102 def do_load(self,args): | 103 def do_load(self,args): |
103 '''Runs query_load10g defined above, to display OS load on cluster nodes (10gRAC)''' | 104 '''Runs query_load10g defined above, to display OS load on cluster nodes (10gRAC) |
105 Do not confuse with `GET myfile.sql` and `@myfile.sql`, | |
106 which get and run SQL scripts from disk.''' | |
104 self.do_select(self.query_load10g) | 107 self.do_select(self.query_load10g) |
105 | 108 |
106 def do_himom(self,args): | 109 def do_himom(self,args): |
107 '''greets your mom''' | 110 '''greets your mom''' |
108 print 'hi mom' | 111 print 'hi mom' |