changeset 306:ed02c8b1a9b6

folded in py session work
author catherine@dellzilla
date Wed, 25 Mar 2009 14:37:34 -0400
parents 9c727d6afdc0 (diff) f7daca26cc00 (current diff)
children e804c08292b3
files docs/source/comparison.rst sqlpython/sqlpyPlus.py
diffstat 2 files changed, 23 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/docs/source/comparison.rst	Wed Mar 25 14:08:30 2009 -0400
+++ b/docs/source/comparison.rst	Wed Mar 25 14:37:34 2009 -0400
@@ -172,7 +172,8 @@
 the history of SQL\*Plus commands issued during the session.  SQL\*Plus on UNIX does not provide this feature.  You can restore the feature, however, by installing a free GNU tool called `rlwrap`, then invoking SQL*\Plus under it: `rlwrap sqlplus me@instance`.
 `rlwrap` can also provide cursor-key history to senora, and in fact to any command-line program. 
 
-Gqlplus, YASQL, and sqlpython provide cursor-key command history out of the box.
+Gqlplus and sqlpytyhon provide cursor-key command history out of the box; Senora and YASQL do also, provided
+that the Term::ReadLine::Perl module has been installed (see Installation).
 
 In addition, senora and sqlpython have a `history` or `hi` command that gives a numbered list of all commands issued in the session.  
 
@@ -748,7 +749,7 @@
 
   $ cpan
   
-  cpan> install DBI 
+  cpan> install DBI Term::ReadLine::Perl
   cpan> force install DBD::Oracle
 
 If this is your first time running `cpan`, it will ask you many configuration questions
@@ -771,7 +772,7 @@
 
   cpan> install DBI 
   cpan> force install DBD::Oracle
-  cpan> install Term::ReadKey Text::CSV_XS Time::HiRes 
+  cpan> install Term::ReadKey Text::CSV_XS Time::HiRes Term::ReadLine::Perl
 
 Download yasql-1.83.tar.gz from http://sourceforge.net/projects/yasql/, unzip and untar it, and
 cd into yasql-1.83.  Run `./configure`, `make`, and (as root) `make install`.
@@ -796,10 +797,15 @@
 The -UZ flags, though optional, will update your sqlpython installation, if necessary, and 
 unzip the code so that you can modify it.
 
-To generate graphs using sqlpython's `\\b`, `\\g`, and `\\l` terminators, you will need to install `pylab`::
+To generate graphs using sqlpython's `\\b`, `\\g`, and `\\l` terminators, you will need to install `pylab` (or `matplotlib`)::
 
   $ easy_install pylab
 
+  $ apt-get install python-matplotlib
+  
+Alternately, a Windows installer is available at http://pypi.python.org/pypi/sqlpython, though easy_install
+works on Windows as well.
+
 ===================
 Extending the tools 
 ===================
@@ -867,7 +873,7 @@
     jrrt@orcl> greet -u World
     HELLO WORLD!
 
-Senora v1.0.1 includes a command, `lregister`, that automatically creates a new senora plugin from
+Senora v0.6 includes a command, `lregister`, that will automatically create a new senora plugin from
 SQL commands in a file.  This will make an incredibly easy way to make your own senora 
 commands for your favorite tasks.
 
--- a/sqlpython/sqlpyPlus.py	Wed Mar 25 14:08:30 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Wed Mar 25 14:37:34 2009 -0400
@@ -23,7 +23,6 @@
 
 - catherinedevlin.blogspot.com  May 31, 2006
 """
-#TODO: html escaping; prompt/accept; sqlpath; LOCAL name; python from stdin
 import sys, os, re, sqlpython, cx_Oracle, pyparsing, re, completion, datetime, pickle, binascii, subprocess
 from cmd2 import Cmd, make_option, options, Statekeeper, Cmd2TestCase
 from output_templates import output_templates
@@ -514,17 +513,14 @@
         '''
         return Cmd.do_py(self, arg)
 
-    argument_grammar =   pyparsing.QuotedString('"') | pyparsing.QuotedString("'") \
-                       | pyparsing.Word(pyparsing.printables)                       
     def do_get(self, args):
         """
         `get {script.sql}` or `@{script.sql}` runs the command(s) in {script.sql}.
         If additional arguments are supplied, they are assigned to &1, &2, etc.
         """        
-        args = args.split(None,1)
-        fname, args = args[0], (args[1:] or [''])[0]
-        for (idx, arg) in enumerate(self.argument_grammar.scanString(args)):
-            self.substvars[str(idx+1)] = arg[0][0]
+        fname, args = args.split()[0], args.split()[1:]
+        for (idx, arg) in enumerate(args):
+            self.substvars[str(idx+1)] = arg
         return Cmd.do__load(self, fname)
     
     def onecmd_plus_hooks(self, line):                          
@@ -537,6 +533,12 @@
             self.curs.callproc('dbms_output.enable', [])        
         else:
             self.curs.callproc('dbms_output.disable', [])        
+        
+    def do_shortcuts(self,arg):
+        """Lists available first-character shortcuts
+        (i.e. '!dir' is equivalent to 'shell dir')"""
+        for (scchar, scto) in self.shortcuts.items():
+            print '%s: %s' % (scchar, scto)
 
     tableNameFinder = re.compile(r'from\s+([\w$#_"]+)', re.IGNORECASE | re.MULTILINE | re.DOTALL)          
     inputStatementFormatters = {
@@ -711,7 +713,7 @@
             prompt = ''
         varname = args.lower().split()[0]
         self.substvars[varname] = self.pseudo_raw_input(prompt)
-        
+                
     def ampersand_substitution(self, raw, regexpr, isglobal):
         subst = regexpr.search(raw)
         while subst:
@@ -843,11 +845,11 @@
                     for ddlargs in ddl:
                         try:
                             code = str(self.curs.callfunc('DBMS_METADATA.GET_DDL', cx_Oracle.CLOB, ddlargs))
-                            if opts.lines:
+                            if hasattr(opts, 'lines') and opts.lines:
                                 code = code.splitlines()
                                 template = "%%-%dd:%%s" % len(str(len(code)))
                                 code = '\n'.join(template % (n+1, line) for (n, line) in enumerate(code))
-                            if opts.num is not None:
+                            if hasattr(opts, 'num') and (opts.num is not None):
                                 code = code.splitlines()
                                 code = centeredSlice(code, center=opts.num+1, width=opts.width)
                                 code = '\n'.join(code)
@@ -1276,10 +1278,6 @@
         except StopIteration:
             return ''.join(arg.split()[:1]), ''
         
-    def do_column(self, arg):
-        'COLUMN keyword not supported by sqlpython'
-        print self.do_column.__doc__
-        
     assignmentScanner = Parser(pyparsing.Literal(':=') ^ '=')
     def interpret_variable_assignment(self, arg):
         '''