[DB-SIG] Proposed DB-API extensions
gh at ghaering.de
Wed Mar 19 13:23:26 CET 2008
I'd like to propose the attached changes to the DB-API spec. My main
motivation is to make DB-API modules less cumbersome to use when used
If you want to try it out live, everything except .fetchscalar() is
already implemented in pysqlite. The __enter__/__exit__ thing is in
pysqlite and cx_Oracle.
==> .execute(), .executemany() returning self.
Ability to write shorter code. No more:
for row in cur:
for row in cur.exeucte("..."):
==> .execute(), .executemany() in connection object.
They should have been placed here anyway. *cough* Users shouldn't have
to mess with cursor objects normally. Ability to write shorter code:
con = module.connect(...)
for row in con.execute("..."):
==> __enter__ and __exit__ in the connection object.
Ability to automatically wrap database code in transactions, when using
Python 2.5 or higher:
cur = con.cursor()
==> fetchscalar method in cursor object
This one is low-prio for me, but it's a common use case to only query a
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the DB-SIG