while (some condition):
rd=crs.execute( """INSERT INTO db
VALUES (%s...)""", data...)
print >> f, "%format" % data
. . .
About 100 INSERTs executed every time this script runs. But when I compare data in MySQL table and plain file (written with printf >> f), I see that not all information stored in MySQL, i.e. some INSERTs are not executed.
How can I check result of cursor.execute()? According to Python DB API 2.0 returning value is not defined :((
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello!
I'm a newby in Python, sorry for lame-question :)
Look (pseudo-code):
crs=db.cursor()
f=open("file")
while (some condition):
rd=crs.execute( """INSERT INTO db
VALUES (%s...)""", data...)
print >> f, "%format" % data
. . .
About 100 INSERTs executed every time this script runs. But when I compare data in MySQL table and plain file (written with printf >> f), I see that not all information stored in MySQL, i.e. some INSERTs are not executed.
How can I check result of cursor.execute()? According to Python DB API 2.0 returning value is not defined :((
While the DB-API 2.0 doesn't define the return value from execute(), DB_API 1.0 defined it as the number of rows affected. MySQLdb also returns this.
Another (better) way to find this out is to look at crs.rowcount, which is a DB-API 2.0 extension.