[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-db-sig
Subject:    [DB-SIG] Announcing adodbapi version 2.6
From:       "Vernon D. Cole" <vernondcole () gmail ! com>
Date:       2014-05-02 0:48:34
Message-ID: CAH-ZgAeMUEsurPRqk+GWH08XYAihK_Bp8ike=R85g7bN0O918g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


For more information, see http://adodbapi.sourceforge.net

Tests were run against various combinations of:
[Python2.5, Python2.7, Python3.3, Python3.4, IronPython2.7]
[32-bit, 64-bit]  [local, remote]
[Access database, SQL Server, PostgreSQL, MySQL]

This release adds prepared query support using the api we have discussed
recently on this forum:
>>> crsr = conn.cursor()
>>> crsr.prepare('select * from sometable where whatever = ?')
>>> crsr.execute(crsr.command, [param])

I have also done more experimentation and enhancement with the
user-definable paramstyle.

This version adds support for setting the paramstyle to 'pyformat', which
is implemented as a synonym of 'format'.  The 'format' SQL-mangling
subroutine now uses introspection to determine whether to use %(keyword)s
or %s positional parameters.  I believe that several of the popular api
implementations work that way.

I also wanted to try a similar feature between 'qmark' and 'named', but
without having to use introspection.  Here is how the code turned out:

def _reformat_operation(self, operation, parameters):
> ..if self.paramstyle in ('format', 'pyformat'): # convert %s to ?
> ....operation, self._parameter_names = api.changeFormatToQmark(operation)
> ..elif self.paramstyle == 'named' or (self.paramstyle == 'dynamic' and
> isinstance(parameters, Mapping)):
> ....operation, self._parameter_names = api.changeNamedToQmark(operation) #
> convert :name to ?
> ..return operation
>

I also had to import 'Mapping' and add 'dynamic' to the list of accepted
paramstyles, so the entire feature changed or added three lines of Python.

[Restriction:  There is a bug in pywin32 version 218 for Python3.4 which
causes a unittest failure. The fix should be released in a few days.]

[Attachment #5 (text/html)]

<div dir="ltr"><div><div><div>For more information, see <a \
href="http://adodbapi.sourceforge.net">http://adodbapi.sourceforge.net</a><br><br>Tests \
were run against various combinations of:<br></div><div>[Python2.5, Python2.7, \
Python3.3, Python3.4, IronPython2.7]<br>

</div><div>[32-bit, 64-bit]   [local, remote]<br></div><div>[Access database, SQL \
Server, PostgreSQL, MySQL]<br><br></div><div>This release adds prepared query support \
using the api we have discussed recently on this forum:<br>

</div>&gt;&gt;&gt; crsr = conn.cursor()<br></div>&gt;&gt;&gt; \
crsr.prepare(&#39;select * from sometable where whatever = \
?&#39;)<br></div>&gt;&gt;&gt; crsr.execute(crsr.command, \
[param])<br><br><div><div><div>I have also done more experimentation and enhancement \
with the user-definable paramstyle.<br>

</div><div><br>This version adds support for setting the paramstyle to \
&#39;pyformat&#39;, which is implemented as a synonym of &#39;format&#39;.   The \
&#39;format&#39; SQL-mangling subroutine now uses introspection to determine whether \
to use %(keyword)s or %s positional parameters.   I believe that several of the \
popular api implementations work that way.<br>

<br></div><div>I also wanted to try a similar feature between &#39;qmark&#39; and \
&#39;named&#39;, but without having to use introspection.   Here is how the code \
turned out:<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex" class="gmail_quote">

def _reformat_operation(self, operation, parameters):<br>..if self.paramstyle in \
(&#39;format&#39;, &#39;pyformat&#39;): # convert %s to ?<br>....operation, \
self._parameter_names = api.changeFormatToQmark(operation)<br>..elif self.paramstyle \
== &#39;named&#39; or (self.paramstyle == &#39;dynamic&#39; and \
isinstance(parameters, Mapping)):<br>

....operation, self._parameter_names = api.changeNamedToQmark(operation) # convert \
:name to ?<br>..return operation<br></blockquote><div><br></div><div>I also had to \
import &#39;Mapping&#39; and add &#39;dynamic&#39; to the list of accepted \
paramstyles, so the entire feature changed or added three lines of Python.<br>

<br></div><div>[Restriction:   There is a bug in pywin32 version 218 for Python3.4 \
which causes a unittest failure. The fix should be released in a few \
days.]<br><br></div></div></div></div></div>



_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
https://mail.python.org/mailman/listinfo/db-sig


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic