# HG changeset patch
# User catherine@dellzilla
# Date 1222439617 14400
# Node ID 3b1e25cc0e38f2d6c27962911593c28454b4ba40
# Parent fcb19853cd942fd6e3c11c0249957aa65ef182cb
html output now valid xhtml 1.0 strict
diff -r fcb19853cd94 -r 3b1e25cc0e38 mysqlpy.py
--- a/mysqlpy.py Thu Sep 25 16:37:16 2008 -0400
+++ b/mysqlpy.py Fri Sep 26 10:33:37 2008 -0400
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# MySqlPy V1.4.8
+# MySqlPy V1.4.9
# Author: Luca.Canali@cern.ch
#
#
@@ -13,9 +13,9 @@
class mysqlpy(sqlpyPlus):
'''
-MySqlPy V1.4.8 - 'sqlplus in python'
+MySqlPy V1.4.9 - 'sqlplus in python'
Author: Luca.Canali@cern.ch
-Rev: 1.4.8, 04-Sep-08
+Rev: 1.4.9, 26-Sep-08
Companion of SqlPython, a python module that reproduces Oracle's command line within python
and sqlpyPlus. Major contributions by Catherine Devlin, http://catherinedevlin.blogspot.com
diff -r fcb19853cd94 -r 3b1e25cc0e38 output_templates.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/output_templates.py Fri Sep 26 10:33:37 2008 -0400
@@ -0,0 +1,47 @@
+import genshi.template
+
+xml_template = genshi.template.NewTextTemplate("""
+
+ <${tblname}_resultset>{% for row in rows %}
+ <$tblname>{% for (colname, itm) in zip(colnames, row) %}
+ <${colname.lower()}>$itm${colname.lower()}>{% end %}
+ $tblname>{% end %}
+ ${tblname}_resultset>
+""")
+
+html_template = genshi.template.MarkupTemplate("""
+
+
+
+ Table Name
+
+
+
+
+
+
+ Column Name
+ |
+
+
+
+ Value
+ |
+
+
+
+""")
+
+list_template = genshi.template.NewTextTemplate("""
+{% for (rowNum, row) in enumerate(rows) %}
+**** Row: ${rowNum + 1}
+{% for (colname, itm) in zip(colnames, row) %}$colname: $itm
+{% end %}{% end %}""")
+
+aligned_list_template = genshi.template.NewTextTemplate("""
+{% for (rowNum, row) in enumerate(rows) %}
+**** Row: ${rowNum + 1}
+{% for (colname, itm) in zip(colnames, row) %}${colname.ljust(colnamelen)}: $itm
+{% end %}{% end %}""")
diff -r fcb19853cd94 -r 3b1e25cc0e38 setup.py
--- a/setup.py Thu Sep 25 16:37:16 2008 -0400
+++ b/setup.py Fri Sep 26 10:33:37 2008 -0400
@@ -9,14 +9,14 @@
Operating System :: OS Independent""".splitlines()
setup(name="sqlpython",
- version="1.4.8",
+ version="1.4.9",
description="Command-line interface to Oracle",
long_description="Customizable alternative to Oracle's SQL*PLUS command-line interface",
author="Luca Canali",
author_email="luca.canali@cern.ch",
url="https://twiki.cern.ch/twiki/bin/view/PSSGroup/SqlPython",
packages=find_packages(),
- py_modules = ['mysqlpy','completion','sqlpyPlus','sqlpython','pexpecter'],
+ py_modules = ['mysqlpy','completion','sqlpyPlus','sqlpython','pexpecter','output_templates'],
include_package_data=True,
install_requires=['pyparsing','cmd2>=0.3.6','cx_Oracle','genshi'],
keywords = 'client oracle database',
diff -r fcb19853cd94 -r 3b1e25cc0e38 sqlpyPlus.py
--- a/sqlpyPlus.py Thu Sep 25 16:37:16 2008 -0400
+++ b/sqlpyPlus.py Fri Sep 26 10:33:37 2008 -0400
@@ -23,7 +23,9 @@
- catherinedevlin.blogspot.com May 31, 2006
"""
-# note in cmd.cmd about supporting emacs commands?
+import sys, os, re, sqlpython, cx_Oracle, pyparsing, re, completion
+from cmd2 import Cmd, make_option, options, Statekeeper
+from output_templates import *
descQueries = {
'TABLE': ("""
@@ -186,9 +188,6 @@
"""
}
-import sys, os, re, sqlpython, cx_Oracle, pyparsing, re, completion, genshi
-from cmd2 import Cmd, make_option, options, Statekeeper
-
if float(sys.version[:3]) < 2.3:
def enumerate(lst):
return zip(range(len(lst)), lst)
@@ -407,50 +406,6 @@
(self.tblname, ','.join(self.colnames), formatRow(row))
for row in self.rows]
return '\n'.join(result)
-
- xml_template = genshi.template.NewTextTemplate("""
-
- <${tblname}_resultset>{% for row in rows %}
- <$tblname>{% for (colname, itm) in zip(colnames, row) %}
- <${colname.lower()}>$itm${colname.lower()}>{% end %}
- $tblname>{% end %}
- ${tblname}_resultset>
-""")
-
- html_template = genshi.template.MarkupTemplate("""
-
-
- Table Name
-
-
-
-
-
- Column Name
- |
-
-
-
- Value
- |
-
-
-
-""")
-
- list_template = genshi.template.NewTextTemplate("""
-{% for (rowNum, row) in enumerate(rows) %}
-**** Row: ${rowNum + 1}
-{% for (colname, itm) in zip(colnames, row) %}$colname: $itm
-{% end %}{% end %}""")
-
- aligned_list_template = genshi.template.NewTextTemplate("""
-{% for (rowNum, row) in enumerate(rows) %}
-**** Row: ${rowNum + 1}
-{% for (colname, itm) in zip(colnames, row) %}${colname.ljust(colnamelen)}: $itm
-{% end %}{% end %}""")
tableNameFinder = re.compile(r'from\s+([\w$#_"]+)', re.IGNORECASE | re.MULTILINE | re.DOTALL)
def output(self, outformat, rowlimit):
@@ -459,12 +414,12 @@
if outformat == '\\i':
result = self.output_as_insert_statements()
elif outformat == '\\x':
- result = self.xml_template.generate(**self.__dict__)
+ result = xml_template.generate(**self.__dict__)
elif outformat == '\\g':
- result = self.list_template.generate(**self.__dict__)
+ result = list_template.generate(**self.__dict__)
elif outformat == '\\G':
self.colnamelen = max(len(colname) for colname in self.colnames)
- result = self.aligned_list_template.generate(**self.__dict__)
+ result = aligned_list_template.generate(**self.__dict__)
elif outformat in ('\\s', '\\S', '\\c', '\\C'): #csv
result = []
if outformat in ('\\s', '\\c'):
@@ -473,7 +428,7 @@
result.append(','.join('"%s"' % self.str_or_empty(itm) for itm in row))
result = '\n'.join(result)
elif outformat == '\\h':
- result = self.html_template.generate(**self.__dict__)
+ result = html_template.generate(**self.__dict__)
elif outformat == '\\t': # transposed
rows = [self.colnames]
rows.extend(list(self.rows))
@@ -959,7 +914,7 @@
def do_cat(self, arg):
'''cat TABLENAME --> SELECT * FROM equivalent'''
- targets = arg.split()
+ targets = arg.strip().split()
for target in targets:
self.do_select('* from %s' % target)
diff -r fcb19853cd94 -r 3b1e25cc0e38 sqlpython.py
--- a/sqlpython.py Thu Sep 25 16:37:16 2008 -0400
+++ b/sqlpython.py Fri Sep 26 10:33:37 2008 -0400
@@ -1,5 +1,5 @@
#
-# SqlPython V1.4.7
+# SqlPython V1.4.9
# Author: Luca.Canali@cern.ch, Apr 2006
# Rev 29-May-08
#