diff sqlpyPlus.py @ 78:8529876f7541

ls working
author catherine@cordelia
date Sun, 27 Apr 2008 08:40:28 -0400
parents 4b5d4e5798dd
children 01d578f4e6e7
line wrap: on
line diff
--- a/sqlpyPlus.py	Tue Apr 22 09:32:55 2008 -0400
+++ b/sqlpyPlus.py	Sun Apr 27 08:40:28 2008 -0400
@@ -807,6 +807,37 @@
     def do_declare(self, arg):
         self.anon_plsql('declare ' + arg)
             
+    def do_create(self, arg):
+        self.anon_plsql('create ' + arg)
+
+    lsflags = flagReader.FlagSet([flagReader.Flag('long')])            
+    def do_ls(self, arg):
+        options, arg = self.lsflags.parse(arg)
+        where = ''
+        if arg:
+            where = """\nWHERE object_type || '/' || object_name
+                         LIKE '%%%s%%'""" % (arg.upper().replace('*','%'))
+        else:
+            where = ''
+        result = []
+        statement = '''SELECT object_type, object_name,
+                              status, last_ddl_time
+                       FROM   user_objects %s
+                       ORDER BY object_type, object_name''' % (where)
+        self.curs.execute(statement)
+        for (object_type, object_name, status, last_ddl_time) in self.curs.fetchall():
+            if options.has_key('long'):
+                result.append('%s\t%s\t%s/%s' % (status, last_ddl_time, object_type, object_name))
+            else:
+                result.append('%s/%s' % (object_type, object_name))
+        self.stdout.write('\n'.join(result) + '\n')
+            
+            
+        if options.has_key('insensitive'):
+            searchfor = "LOWER(text)"
+            arg = arg.lower()
+            
+            
     def do_cat(self, arg):
         targets = arg.split()
         for target in targets: