[DB-SIG] Towards a single parameter style
M.-A. Lemburg
mal@lemburg.com
Mon, 17 Feb 2003 23:18:53 +0100
Gerhard H=E4ring wrote:
> * Kevin Jacobs <jacobs@penguin.theopalgroup.com> [2003-02-17 15:14 -050=
0]:
>=20
>>[...] here are a few things I'd rather get from DB-API 3000:
>>
>>connection =3D driver.connect(...)
>>statement =3D connection.prepare(sql)
>>print statement.description
>>cursor =3D statement.execute(param1, param2, param3)
>>cursor.fetchall()
>=20
> Looks good :-)
>=20
>>Of course, this syntax _requires_ that the backend support prepared
>>statements, instead of trying to piggyback it on to the regular execute
>>syntax.
>=20
> How so? A driver could still emulate prepared statements, couldn't it?
FWIW, you can emulate this with the standard DB API (and without
introducing yet another object type which causes even more
work for the module author):
cursor.prepare(sql) # this prepares the comman sql and sets
# cursor.command to sql
cursor.execute(cursor.command, params)
--=20
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Feb 17 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
Python UK 2003, Oxford: 43 days left
EuroPython 2003, Charleroi, Belgium: 127 days left