Mercurial > sqlpython
comparison sqlpyPlus.py @ 61:1eefe17b3630
adding more psql \d commands
author | catherine@cordelia |
---|---|
date | Thu, 03 Apr 2008 11:21:26 -0400 |
parents | de6278a3bf53 |
children | 833e9d251da3 |
comparison
equal
deleted
inserted
replaced
59:3828db4f3c94 | 61:1eefe17b3630 |
---|---|
686 \h help | 686 \h help |
687 \i getrun | 687 \i getrun |
688 \o spool | 688 \o spool |
689 \p list | 689 \p list |
690 \w save | 690 \w save |
691 \db _dir_tablespaces | |
692 \dd comments | |
693 \dn _dir_schemas | |
694 \dt _dir_tables | |
695 \dv _dir_views | |
696 \di _dir_indexes | |
691 \? help psql''' | 697 \? help psql''' |
692 commands = {} | 698 commands = {} |
693 for c in self.do_psql.__doc__.splitlines()[2:]: | 699 for c in self.do_psql.__doc__.splitlines()[2:]: |
694 (abbrev, command) = c.split(None, 1) | 700 (abbrev, command) = c.split(None, 1) |
695 commands[abbrev[1:]] = command | 701 commands[abbrev[1:]] = command |
701 args = '' | 707 args = '' |
702 try: | 708 try: |
703 self.onecmd('%s %s' % (commands[abbrev], args)) | 709 self.onecmd('%s %s' % (commands[abbrev], args)) |
704 self.onecmd('q') | 710 self.onecmd('q') |
705 except KeyError: | 711 except KeyError: |
706 print 'psql command \%s not yet supported.' % abbrev | 712 print 'psql command \%s not yet supported.' % abbrev |
713 | |
714 def do__dir_tables(self, arg): | |
715 self.do_select("""table_name, 'TABLE' as type, owner FROM all_tables WHERE table_name LIKE '%%%s%%'""" % arg.upper()) | |
716 | |
717 def do__dir_views(self, arg): | |
718 self.do_select("""view_name, 'VIEW' as type, owner FROM all_views WHERE view_name LIKE '%%%s%%'""" % arg.upper()) | |
719 | |
720 def do__dir_indexes(self, arg): | |
721 self.do_select("""index_name, index_type, owner FROM all_indexes WHERE index_name LIKE '%%%s%%' OR table_name LIKE '%%%s%%'""" % (arg.upper(), arg.upper())) | |
722 | |
723 def do__dir_tablespaces(self, arg): | |
724 self.do_select("""tablespace_name, file_name from dba_data_files""") | |
725 | |
726 def do__dir_schemas(self, arg): | |
727 self.do_select("""owner, count(*) AS objects FROM all_objects GROUP BY owner ORDER BY owner""") | |
707 | 728 |
708 def do_print(self, arg): | 729 def do_print(self, arg): |
709 'print VARNAME: Show current value of bind variable VARNAME.' | 730 'print VARNAME: Show current value of bind variable VARNAME.' |
710 if arg: | 731 if arg: |
711 if arg[0] == ':': | 732 if arg[0] == ':': |
712 arg = arg[1:] | 733 arg = arg[1:] |
713 try: | 734 try: |
714 self.stdout.write(self.binds[arg]+'\n') | 735 self.stdout.write(self.binds[arg]+'\n') |
715 except KeyError: | 736 except KeyError: |