C
Carl K
using MySQLdb, I do cursor.execute("update...")
How can I tell how many rows were affected ?
Carl K
How can I tell how many rows were affected ?
Carl K
Carl said:using MySQLdb, I do cursor.execute("update...")
How can I tell how many rows were affected ?
Carl K
John said:cursor = db.cursor() # get cursor
cursor.execute(sqlstatement, argtuple) # do command
rowsaffected = cursor.rowcount # get count of rows affected
cursor.close() # close cursor
db.commit() # commit transaction
John Nagle
cursor = db.cursor() # get cursor
cursor.execute(sqlstatement, argtuple) # do command
---=-=-=-=-=-=-
rowsaffected = cursor.rowcount # get count of rows affected
cursor.close() # close cursor
db.commit() # commit transaction
John Nagle
Dennis said:According to the documentation, it may be possible to get the result
with
rws = cursor.execute(...)
-=-=-=-=-=-=-
Help on method execute in module MySQLdb.cursors:
execute(self, query, args=None) method of MySQLdb.cursors.Cursor
instance
Execute a query.
query -- string, query to execute on server
args -- optional sequence or mapping, parameters to use with query.
Note: If args is a sequence, then %s must be used as the
parameter placeholder in the query. If a mapping is used,
%(key)s must be used as the placeholder.
Returns long integer rows affected, if any
-=-=-=-=-=-=-
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.