On 2007-05-23 07:29, Carsten Haese wrote:
> On Tue, 22 May 2007 17:08:46 -0400, Art Protin wrote
>> Separating out the query would greatly reduce the confusion between
>> parameters
>> and string formatting as then the two would be in separate commands.
>
> Ah, you mean a "prepared statement" object. This topic comes up from time to
> time, but there are at least two DB-API implementations (InformixDB and either
> mxODBC or cxOracle, or maybe both) that allow prepared statements without the
> clutter of a Query object: The cursor object *is* the query object, in
> essence.
Just to confirm: mxODBC does support this approach and it works
great for caching cursors with readily prepared statements
in long running applications.
> For example, in InformixDB you can write:
>
> conn = informixdb.connect("test")
> cur = conn.cursor()
> cur.prepare("select * from customer where cust_num = ?")
> # later...
> cur.execute(cur.command, (1,) )
>
> Instead of cur.command, InformixDB also allows passing None as the statement,
> which makes for shorter code if the cursor has a long name, which it might,
> since the cursor is being used like a prepared statement, so its name should
> reflect what it does.
The idea behind having cur.command stems from an old optimization
that we have in DB-API: if the interface detects that the same
command is used for execution, it may reuse the already prepared
statement for that command.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, May 23 2007)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX 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
_______________________________________________
DB-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/db-sig