changeset 178:3ce72ea76768

adding tests
author catherine@dellzilla
date Tue, 28 Oct 2008 16:44:51 -0400
parents 87eb1c6ed59b
children 7e3921829399
files sqlpython/exampleSession.txt sqlpython/sqlpyPlus.py
diffstat 2 files changed, 177 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/exampleSession.txt	Tue Oct 28 16:12:58 2008 -0400
+++ b/sqlpython/exampleSession.txt	Tue Oct 28 16:44:51 2008 -0400
@@ -57,6 +57,179 @@
 
 Executed
 
-#testschema@eqtest> drop table play;
+testschema@eqtest> comments play
+TABLE TESTSCHEMA.PLAY: I like plays.
+
+COLUMN_NAME COMMENTS
+----------- ----------------------------
+TITLE       None
+AUTHOR      Primary author (if multiple)
+
+2 rows selected.
+
+testschema@eqtest> cat play
+
+TITLE         AUTHOR
+------------- -----------
+Twelfth Night Shakespeare
+The Tempest   Shakespeare
+Agamemnon     Aeschylus
+
+3 rows selected.
+
+testschema@eqtest> help terminators
+;    standard Oracle format
+\c   CSV (with headings)
+\C   CSV (no headings)
+\g   list
+\G   aligned list
+\h   HTML table
+\i   INSERT statements
+\s   CSV (with headings)
+\S   CSV (no headings)
+\t   transposed
+\x   XML
+\l   line plot, with markers
+\L   scatter plot (no lines)
+\b   bar graph
+\p   pie chart
+testschema@eqtest> select * from play where author='Shakespeare'\c
+
+"TITLE","AUTHOR"
+"Twelfth Night","Shakespeare"
+"The Tempest","Shakespeare"
+
+2 rows selected.
+
+testschema@eqtest> select * from play where author='Shakespeare'\g
+
+
+
+**** Row: 1
+TITLE: Twelfth Night
+AUTHOR: Shakespeare
+
+**** Row: 2
+TITLE: The Tempest
+AUTHOR: Shakespeare
+
+
+2 rows selected.
+
+testschema@eqtest> select * from play where author='Shakespeare'\h
 
-Executed
\ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <title>play</title>
+    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
+  </head>
+  <body>
+    <table id="play" summary="Result set from query on table play">
+      <tr>
+        <th id="header_title">
+          title
+        </th><th id="header_author">
+          author
+        </th>
+      </tr>
+      <tr>
+        <td headers="header_title">
+          Twelfth Night
+        </td><td headers="header_author">
+          Shakespeare
+        </td>
+      </tr><tr>
+        <td headers="header_title">
+          The Tempest
+        </td><td headers="header_author">
+          Shakespeare
+        </td>
+      </tr>
+    </table>
+  </body>
+</html>
+
+2 rows selected.
+
+testschema@eqtest> select * from play where author='Shakespeare'\i
+
+INSERT INTO play (TITLE,AUTHOR) VALUES ('Twelfth Night','Shakespeare');
+INSERT INTO play (TITLE,AUTHOR) VALUES ('The Tempest','Shakespeare');
+
+2 rows selected.
+
+testschema@eqtest> select * from play where author='Shakespeare'\t
+
+
+COLUMN NAME ROW N.1       ROW N.2
+----------- ------------- -----------
+TITLE       Twelfth Night The Tempest
+AUTHOR      Shakespeare   Shakespeare
+
+2 rows selected.
+
+testschema@eqtest> select * from play where author='Shakespeare'\x
+
+
+<xml>
+  <play_resultset>
+    <play>
+      <title>Twelfth Night</title>
+      <author>Shakespeare</author>
+    </play>
+    <play>
+      <title>The Tempest</title>
+      <author>Shakespeare</author>
+    </play>
+  </play_resultset>
+</xml>
+
+2 rows selected.    
+
+testschema@eqtest> set
+maxtselctrows: 10
+maxfetch: 1000
+autobind: False
+failover: False
+timeout: 30
+commit_on_exit: True
+testschema@eqtest> set autobind on
+autobind - was: False
+now: True
+testschema@eqtest> select * from play where author like 'A%';
+
+TITLE     AUTHOR
+--------- ---------
+Agamemnon Aeschylus
+
+1 row selected.
+
+testschema@eqtest> print
+:title = Agamemnon
+:author = Aeschylus
+testschema@eqtest> select * from play where author = :author;
+
+TITLE     AUTHOR
+--------- ---------
+Agamemnon Aeschylus
+
+1 row selected.
+
+testschema@eqtest> help grep
+grep PATTERN TABLE - search for term in any of TABLE's fields
+Usage: grep [options] arg
+
+Options:
+  -h, --help         show this help message and exit
+  -i, --ignore-case  Case-insensitive search
+
+testschema@eqtest> grep -i EM play
+play
+
+TITLE       AUTHOR
+----------- -----------
+The Tempest Shakespeare
+Agamemnon   Aeschylus
+
+2 rows selected.
\ No newline at end of file
--- a/sqlpython/sqlpyPlus.py	Tue Oct 28 16:12:58 2008 -0400
+++ b/sqlpython/sqlpyPlus.py	Tue Oct 28 16:44:51 2008 -0400
@@ -849,6 +849,8 @@
 
     assignmentScanner = Parser(pyparsing.Literal(':=') ^ '=')
     def do_setbind(self, arg):
+        if not arg:
+            return self.do_print(arg)
         arg = self.parsed(arg).unterminated
         try:
             assigner, startat, endat = self.assignmentScanner.scanner.scanString(arg).next()