1.1 --- a/PKG-INFO Sat Jun 02 20:36:06 2007 +0200
1.2 +++ b/PKG-INFO Sun Aug 12 20:31:11 2007 +0200
1.3 @@ -1,18 +1,18 @@
1.4 Metadata-Version: 1.1
1.5 Name: sqlliterals
1.6 -Version: 0.1
1.7 +Version: 0.2
1.8 Author: Paul Boddie
1.9 Author-email: paul at boddie org uk
1.10 Maintainer: Paul Boddie
1.11 Maintainer-email: paul at boddie org uk
1.12 Home-page: http://www.python.org/pypi/sqlliterals
1.13 -Download-url: http://www.boddie.org.uk/python/downloads/sqlliterals-0.1.tar.gz
1.14 +Download-url: http://www.boddie.org.uk/python/downloads/sqlliterals-0.2.tar.gz
1.15 Summary: SQL statement tokenisation for the detection of literal regions.
1.16 License: LGPL
1.17 Description: The sqlliterals distribution consists of a package containing two different
1.18 implementations of SQL statement tokenisation for the detection of literal
1.19 regions in such statements.
1.20 -Keywords: SQL pyparsing parsing re
1.21 +Keywords: SQL pyparsing parsing re paramstyle
1.22 Requires: pyparsing
1.23 Classifier: Development Status :: 3 - Alpha
1.24 Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
2.1 --- a/README.txt Sat Jun 02 20:36:06 2007 +0200
2.2 +++ b/README.txt Sun Aug 12 20:31:11 2007 +0200
2.3 @@ -3,7 +3,17 @@
2.4
2.5 The sqlliterals distribution consists of a package containing two different
2.6 implementations of SQL statement tokenisation for the detection of literal
2.7 -regions in such statements.
2.8 +regions in such statements. It also provides a function which can replace
2.9 +one kind of parameter marker with another in statements, subject to the
2.10 +careful choice of the original parameter marker (since the replacement process
2.11 +builds on the above tokenisation process and the identification of non-literal
2.12 +regions).
2.13 +
2.14 +Examples
2.15 +--------
2.16 +
2.17 +See the test.py file for some tests and simple examples which use the parsing/
2.18 +tokenising and replacement functions.
2.19
2.20 Contact, Copyright and Licence Information
2.21 ------------------------------------------
2.22 @@ -25,6 +35,13 @@
2.23
2.24 pyparsing Tested with 1.2
2.25
2.26 +New in sqlliterals 0.2 (Changes since sqlliterals 0.1)
2.27 +------------------------------------------------------
2.28 +
2.29 + * Added a replace function to the different modules which permits the
2.30 + replacement of carefully chosen parameter markers with markers having a
2.31 + different representation.
2.32 +
2.33 Release Procedures
2.34 ------------------
2.35
3.1 --- a/sqlliterals/__init__.py Sat Jun 02 20:36:06 2007 +0200
3.2 +++ b/sqlliterals/__init__.py Sun Aug 12 20:31:11 2007 +0200
3.3 @@ -20,6 +20,6 @@
3.4 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
3.5 """
3.6
3.7 -__version__ = "0.1"
3.8 +__version__ = "0.2"
3.9
3.10 # vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/sqlliterals/pyparser.py Sat Jun 02 20:36:06 2007 +0200
4.2 +++ b/sqlliterals/pyparser.py Sun Aug 12 20:31:11 2007 +0200
4.3 @@ -20,6 +20,7 @@
4.4 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
4.5 """
4.6
4.7 +import sqlliterals.common
4.8 from pyparsing import *
4.9
4.10 try:
4.11 @@ -63,4 +64,16 @@
4.12 first = 0
4.13 return regions
4.14
4.15 +# NOTE: Duplicated across implementations.
4.16 +
4.17 +def replace(fromstyle, tostyle, s):
4.18 +
4.19 + """
4.20 + Return a new string, where the paramstyle 'fromstyle' is
4.21 + replaced with 'tostyle' in the appropriate regions of 's'.
4.22 + """
4.23 +
4.24 + regions = parseString(s)
4.25 + return "".join(sqlliterals.common.replace(fromstyle, tostyle, regions))
4.26 +
4.27 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/sqlliterals/regexp.py Sat Jun 02 20:36:06 2007 +0200
5.2 +++ b/sqlliterals/regexp.py Sun Aug 12 20:31:11 2007 +0200
5.3 @@ -20,6 +20,7 @@
5.4 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
5.5 """
5.6
5.7 +import sqlliterals.common
5.8 import re
5.9
5.10 region_expr = re.compile("(?P<non_literal>[^']+)|(?P<literal>'(?:[^']|(?:''))*')")
5.11 @@ -47,4 +48,16 @@
5.12
5.13 return regions
5.14
5.15 +# NOTE: Duplicated across implementations.
5.16 +
5.17 +def replace(fromstyle, tostyle, s):
5.18 +
5.19 + """
5.20 + Return a new string, where the paramstyle 'fromstyle' is
5.21 + replaced with 'tostyle' in the appropriate regions of 's'.
5.22 + """
5.23 +
5.24 + regions = parseString(s)
5.25 + return "".join(sqlliterals.common.replace(fromstyle, tostyle, regions))
5.26 +
5.27 # vim: tabstop=4 expandtab shiftwidth=4
6.1 --- a/test.py Sat Jun 02 20:36:06 2007 +0200
6.2 +++ b/test.py Sun Aug 12 20:31:11 2007 +0200
6.3 @@ -33,4 +33,21 @@
6.4 show(sqlliterals.pyparser.parseString(s))
6.5 show(sqlliterals.regexp.parseString(s))
6.6
6.7 +l2 = [
6.8 + "a = ?",
6.9 + "a = '?'",
6.10 + "'a' = ?",
6.11 + "'a' = '?'",
6.12 + "a = ''?''",
6.13 + "'''' = ?",
6.14 + "'''' = ''?''",
6.15 + "a = '''?'''",
6.16 + "'''a''' = ?",
6.17 + "'''a''' = '''?'''"
6.18 + ]
6.19 +
6.20 +for s in l2:
6.21 + print sqlliterals.pyparser.replace("?", "%s", s)
6.22 + print sqlliterals.regexp.replace("?", "%s", s)
6.23 +
6.24 # vim: tabstop=4 expandtab shiftwidth=4