changeset 376:c0df8426dcbd

gerald ls working
author catherine@cordelia
date Wed, 12 Aug 2009 17:03:24 -0400
parents 05758f4bcac1
children 2bbf953ef231
files sqlpython/sqlpyPlus.py sqlpython/sqlpython.py
diffstat 2 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Tue Aug 11 14:53:29 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Wed Aug 12 17:03:24 2009 -0400
@@ -1465,6 +1465,26 @@
         self.do_select(self.parsed(statement, 
                                    terminator=arg.parsed.terminator or ';', 
                                    suffix=arg.parsed.suffix))
+
+        
+    @options([make_option('-l', '--long', action='store_true', help='long descriptions'),
+              make_option('-a', '--all', action='store_true', help="all schemas' objects"),
+              make_option('-t', '--timesort', action='store_true', help="Sort by last_ddl_time"),              
+              make_option('-r', '--reverse', action='store_true', help="Reverse order while sorting")])            
+    def do_ls(self, arg, opts):
+        seek = '^%s$' % (arg.replace('*', '.*').replace('?','.'). \
+                         replace('%', '.*'))
+        gerald = self.connections[self.connection_number]['gerald']
+        for (name, obj) in gerald.schema.items():
+            dbtype = str(type(obj)).rstrip("'>").split('.')[-1]
+            if dbtype == 'CodeObject':
+                dbtype = obj.type
+            descriptor = '%s/%s' % (dbtype, name)
+            if (not arg) or \
+               re.search(seek, descriptor, re.IGNORECASE) or \
+               re.search(seek, name, re.IGNORECASE) or \
+               re.search(seek, dbtype, re.IGNORECASE):
+                self.poutput(descriptor)
         
     @options([make_option('-i', '--ignore-case', dest='ignorecase', action='store_true', help='Case-insensitive search')])        
     def do_grep(self, arg, opts):
--- a/sqlpython/sqlpython.py	Tue Aug 11 14:53:29 2009 -0400
+++ b/sqlpython/sqlpython.py	Wed Aug 12 17:03:24 2009 -0400
@@ -9,8 +9,8 @@
 # See also http://twiki.cern.ch/twiki/bin/view/PSSGroup/SqlPython
 
 import cmd2,getpass,binascii,cx_Oracle,re,os
-import sqlalchemy, pyparsing
-__version__ = '1.6.7'    
+import sqlalchemy, pyparsing, gerald
+__version__ = '1.7.0'    
 
 class Parser(object):
     comment_def = "--" + ~ ('-' + pyparsing.CaselessKeyword('begin')) + pyparsing.ZeroOrMore(pyparsing.CharsNotIn("\n"))    
@@ -138,6 +138,10 @@
             modeval = cx_Oracle.SYSOPER
         result = self.url_connect('oracle://%s:%s@%s/?mode=%d' % (orauser, orapass, oraserv, modeval))
         result['dbname'] = oraserv
+        result['gerald'] = gerald.OracleSchema('schema', 
+                                               'oracle:/%s:%s@%s' % (orauser,
+                                                                     orapass,
+                                                                     oraserv))
         return result
     
     connection_modes = {re.compile(' AS SYSDBA', re.IGNORECASE): cx_Oracle.SYSDBA,