[DB-SIG] Improved support for prepared SQL statements

M.-A. Lemburg mal at egenix.com
Thu Dec 18 11:39:24 CET 2014


On 17.12.2014 19:13, INADA Naoki wrote:
> As I said before, prepared statement is normally bound to connection.
> So `.prepare()` method should be connection's method, not cursor's.
> 
> prepared = conn.prepare("SELECT ?+?")
> ...
> cur = conn.cursor()
> cur.execute(prepared, (1, 2))
> cur.fetchone()  # returns (3,)

I'm not sure which database you are talking about, but in terms
of concepts, statements are run on cursors, so adding the method
to connections doesn't look right (we dropped this logic when moving
from DB-API 1.0 to 2.0 a long time ago).

Also note that the prepare step may need access to the
cursor configuration settings to be correctly interpreted
by the database.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Dec 18 2014)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> mxODBC Plone/Zope Database Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2014-12-11: Released mxODBC Plone/Zope DA 2.2.0   http://egenix.com/go67

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the DB-SIG mailing list