DB API specification of .rowcount and/or execute

A

andychambers2002

Hi,

Should execute() be allowed to execute multiple operations?

e.g.

from dbi import *

conn = connect(database="test")
curs = conn.cursor()
curs.execute("""
INSERT INTO test_table VALUES (1, 'one');
INSERT INTO test_table VALUES(2, 'two');
""")

If so, then given this execution should rowcount contain the value 2?

What if both a select statement and an insert/update statement exist in
a single call to execute?

Perhaps only the rows affected/returned by the last operation in a
given execute() should be given by rowcount?
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Hi,

Should execute() be allowed to execute multiple operations? [...]

You best ask such questions on the DB-SIG. I say "no" and I think most
people there will agree.

Most DB-API modules will accept multiple statements, but that's an
implementation artifact, and not intended by the DB-API.

FWIW I specifically implemented a check in pysqlite that will raise a
Warning if you use multiple statements in execute(many) and provided a
nonstandard executescript() method for those who really want to execute
multiple statements.

-- Gerhard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top