changeset 247:f0f293d83337

begin docs
author catherine@dellzilla
date Wed, 04 Mar 2009 17:44:29 -0500
parents b5d4a122354a
children 230447ce6e60
files docs/source/capabilities.rst docs/source/index.rst docs/source/intro.rst docs/source/limitations.rst sqlpython/sqlpyPlus.py sqlpython/sqlpython.py
diffstat 6 files changed, 130 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/source/capabilities.rst	Wed Mar 04 17:44:29 2009 -0500
@@ -0,0 +1,54 @@
+SQLPython's extra capabilities
+==============================
+
+For the most part, SQLPython simply duplicates SQL\*Plus's capabilites.
+
+UNIX-like commands
+==================
+
+ls
+   Lists objects from the data dictionaries.  There are implied wildcards at the beginning and
+   end
+
+cat
+   Shorthand for "SELECT * FROM"
+
+PostgreSQL-like shortcuts
+=========================
+
+----- ------------------
+z     y
+----- ------------------
+\\c   connect
+\\d   desc
+\\e   edit
+\\g   run
+\\h   help
+\\i   load
+\\o   spool
+\\p   list
+\\q   quit
+\\w   save
+\\db  _dir_tablespaces
+\\dd  comments
+\\dn  _dir_schemas
+\\dt  _dir_tables
+\\dv  _dir_views
+\\di  _dir_indexes
+\\?   help psql
+----- ------------------
+
+Wild SQL
+========
+
+Wild SQL is a nonstandard SQL feature that must be enabled with `set wildsql on`.  When it is
+enabled, column names in a SELECT statement do not need to be explicitly typed.  
+
+* % or \* as wildcards::
+
+  SELECT d* FROM v$database;
+
+  SELECT 
+
+Wild SQL can only be used in the primary column list of straightforward SELECT statements, 
+not in subqueries, `UNION`ed queries, etc.
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/source/index.rst	Wed Mar 04 17:44:29 2009 -0500
@@ -0,0 +1,24 @@
+.. SQLPython documentation master file, created by sphinx-quickstart on Wed Mar  4 15:43:28 2009.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to SQLPython's documentation!
+=====================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   intro
+   capabilities
+   limitations
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/source/intro.rst	Wed Mar 04 17:44:29 2009 -0500
@@ -0,0 +1,14 @@
+Introduction
+============
+
+SQLPython is a command-line interface to Oracle databases.  It is intended as an alternative to Oracle's
+SQL\*Plus.  For the most part, it can be used the same way SQL\*Plus would be used; this documentation
+focuses on the places where SQLPython differs.
+
+SQLPython was created by `Luca Canali <http://canali.web.cern.ch/canali/>_` at CERN.  Most new development
+has been done by `Catherine Devlin <http://catherinedevlin.blogspot.com/>_`.
+
+SQLPython is based on the Python standard library's cmd module, and on an extension to it called cmd2.
+
+SQLPython is currently only compatible with Oracle databases.  Expanding it to other RDBMS is a dream
+for "one fine day".  Call it "SQLPython 3000".
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/source/limitations.rst	Wed Mar 04 17:44:29 2009 -0500
@@ -0,0 +1,30 @@
+===========
+Limitations
+===========
+
+Slow parsing
+------------
+
+After each line of text in a multi-line command is entered, SQLPython pauses to determine whether
+the command is finished yet.  This pause is unnoticable at first, but gradually becomes noticable,
+then annoying, then crippling when very long commands are entered.
+
+This problem can be worked around by bracketing long, individual commands in REMARK BEGIN 
+and REMARK END statements.  When SQLPython finds a REMARK BEGIN, it stops parsing after each
+line and assumes that everything entered until REMARK END is a single statement.
+
+PL/SQL
+------
+
+SQLPython interprets short anonymous PL/SQL blocks correctly, as well as one-line PL/SQL
+commands preceded with `exec`.  For longer blocks, however, it gets confused about where
+the statement begins and ends.
+
+To parse PL/SQL safely, enclose each free-standing PL/SQL block between a REMARK BEGIN and a
+REMARK END statement.
+
+Unsupported commands
+--------------------
+
+  * DBMS_OUTPUT.PUT_LINE
+
--- a/sqlpython/sqlpyPlus.py	Wed Mar 04 14:52:02 2009 -0500
+++ b/sqlpython/sqlpyPlus.py	Wed Mar 04 17:44:29 2009 -0500
@@ -362,13 +362,13 @@
     sqlpython.sqlpython.noSpecialParse.append('spool')
     commentGrammars = pyparsing.Or([pyparsing.Literal('--') + pyparsing.restOfLine, pyparsing.cStyleComment])
     commentGrammars = pyparsing.Or([Parser.comment_def, pyparsing.cStyleComment])
-    defaultFileName = 'afiedt.buf'
+    default_file_name = 'afiedt.buf'
     def __init__(self):
         sqlpython.sqlpython.__init__(self)
         self.binds = CaselessDict()
         self.settable += 'autobind commit_on_exit maxfetch maxtselctrows timeout heading wildsql'.split()
+        self.settable.remove('case_insensitive')
         self.settable.sort()
-        # settables must be lowercase
         self.stdoutBeforeSpool = sys.stdout
         self.spoolFile = None
         self.autobind = False
@@ -412,10 +412,10 @@
         if not line.lower().strip().startswith('begin'):
             return
         statement = []
-        next = self.pseudo_raw_input(self.continuationPrompt)
+        next = self.pseudo_raw_input(self.continuation_prompt)
         while next.lower().split()[:2] != ['remark','end']:
             statement.append(next)
-            next = self.pseudo_raw_input(self.continuationPrompt)
+            next = self.pseudo_raw_input(self.continuation_prompt)
         return self.onecmd('\n'.join(statement))        
     
     def onecmd_plus_hooks(self, line):                          
@@ -730,7 +730,7 @@
         """Displays source code."""
         self._pull(arg, opts)
             
-    supported_ddl_types = 'CLUSTER, CONTEXT, DATABASE LINK, DIRECTORY, FUNCTION, INDEX, JOB, LIBRARY, MATERIALIZED VIEW, PACKAGE, PACKAGE BODY, OPERATOR, PACKAGE, PROCEDURE, SEQUENCE, SYNONYM, TABLE, TRIGGER, VIEW, TYPE, TYPE BODY, XML SCHEMA'
+    supported_ddl_types = 'CLUSTER, CONTEXT, DATABASE LINK, DIRECTORY, FUNCTION, INDEX, JOB, LIBRARY, MATERIALIZED VIEW, PACKAGE, PACKAGE BODY, PACKAGE SPEC, OPERATOR, PACKAGE, PROCEDURE, SEQUENCE, SYNONYM, TABLE, TRIGGER, VIEW, TYPE, TYPE BODY, XML SCHEMA'
     do_pull.__doc__ += '\n\nSupported DDL types: ' + supported_ddl_types
     supported_ddl_types = supported_ddl_types.split(', ')    
 
@@ -1072,7 +1072,7 @@
     def anon_plsql(self, line1):
         lines = [line1]
         while True:
-            line = self.pseudo_raw_input(self.continuationPrompt)
+            line = self.pseudo_raw_input(self.continuation_prompt)
             if line == 'EOF':
                 return
             if line.strip() == '/':
--- a/sqlpython/sqlpython.py	Wed Mar 04 14:52:02 2009 -0500
+++ b/sqlpython/sqlpython.py	Wed Mar 04 17:44:29 2009 -0500
@@ -92,7 +92,8 @@
         
     def default(self, arg):
         self.varsUsed = sqlpyPlus.findBinds(arg, self.binds, givenBindVars={})
-        if arg.parsed.command.lower() in ('create',):
+        ending_args = arg.lower().split()[-2:]
+        if 'end' in ending_args:
             command = '%s %s;'
         else:
             command = '%s %s'