Mercurial > sqlpython
changeset 345:af0e16a5e003
added --refresh option to desc
author | Catherine Devlin <catherine.devlin@gmail.com> |
---|---|
date | Thu, 23 Apr 2009 17:13:31 -0400 |
parents | c2e3223703f2 |
children | 747b325eb98d |
files | sqlpython/sqlpyPlus.py sqlpython/sqlpython.py |
diffstat | 2 files changed, 24 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py Wed Apr 22 10:36:39 2009 -0400 +++ b/sqlpython/sqlpyPlus.py Thu Apr 23 17:13:31 2009 -0400 @@ -889,7 +889,7 @@ @options([all_users_option, make_option('-l', '--long', action='store_true', help='include column #, comments')]) - def do_describe(self, arg, opts): + def _do_describe_oracle(self, arg, opts): "emulates SQL*Plus's DESCRIBE" target = arg.upper() objnameclause = '' @@ -940,9 +940,15 @@ result = datatype return result - @options([make_option('-l', '--long', action='store_true', help='include column #, comments')]) + @options([all_users_option, + make_option('-r', '--refresh', action='store_true', help='Refresh cache of metadata'), + make_option('-l', '--long', action='store_true', help='include column #, comments')]) def do_describe(self, arg, opts): - schema = self.connections[self.connection_number]['gerald']().schema + if self.rdbms == 'oracle': + return self._do_describe_oracle () + if opts.refresh: + self.connections[self.connection_number]['gerald_result'] = self.connections[self.connection_number]['gerald']() + schema = self.connections[self.connection_number]['gerald_result'].schema target = arg.upper().strip() for (objname, obj) in schema.items(): if objname.upper() == target: @@ -1354,8 +1360,8 @@ @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): + make_option('-r', '--reverse', action='store_true', help="Reverse order while sorting")]) + def _do_ls_oracle(self, arg, opts): ''' Lists objects as through they were in an {object_type}/{object_name} UNIX directory structure. `*` and `%` may be used as wildcards. @@ -1384,6 +1390,18 @@ 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): + if self.rdbms == 'oracle': + return self._do_ls_oracle(arg, opts) + ger = self.connections[self.connection_number]['gerald_result'] + + + return + @options([make_option('-i', '--ignore-case', dest='ignorecase', action='store_true', help='Case-insensitive search')]) def do_grep(self, arg, opts): """grep {target} {table} [{table2,...}]
--- a/sqlpython/sqlpython.py Wed Apr 22 10:36:39 2009 -0400 +++ b/sqlpython/sqlpython.py Thu Apr 23 17:13:31 2009 -0400 @@ -106,6 +106,7 @@ 'eng': eng} gerclass = self.gerald_classes[eng.url.drivername] conn['gerald'] = functools.partial(gerclass[0], gerclass[1], arg.split('/?')[:1][0]) + conn['gerald_result'] = conn['gerald']() return conn def ora_connect(self, arg):