mysql "rows affected"
Carl K
carl at personnelware.com
Sun Apr 29 15:22:16 EDT 2007
Dennis Lee Bieber wrote:
> On Thu, 26 Apr 2007 18:18:57 -0700, John Nagle <nagle at animats.com>
> declaimed the following in comp.lang.python:
>
>> Carl K wrote:
>>> using MySQLdb, I do cursor.execute("update...")
>>>
>>> How can I tell how many rows were affected ?
>>>
>>> Carl K
>> cursor = db.cursor() # get cursor
>> cursor.execute(sqlstatement, argtuple) # do command
>
> According to the documentation, it may be possible to get the result
> with
>
> rws = cursor.execute(...)
>
>
> -=-=-=-=-=-=-
>>>> help(cr.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
>
> -=-=-=-=-=-=-
hey look at that. Thanks.
Carl K
More information about the Python-list
mailing list