MySQLdb -- any way to get "rows matched"?

Chris Stromberger bit_bucket5 at hotmail.com
Sun Aug 31 11:43:27 EDT 2003


When issuing updates in mysql (in the console window), mysql will tell
you if any rows matched and how many rows were updated (see below).  I
know how to get number of rows udpated using MySQLdb, but is there any
way to get the number of rows matched?  I want to find out, when rows
updated = 0, if there were no updates because the row wasn't found
(rows matched will = 0) or because the update would not have changed
any data (rows matched = 1).

mysql> select * from test;
+------+------+
| rver | s    |
+------+------+
|    1 | new  |
+------+------+
1 row in set (0.00 sec)

mysql> update test set rver = 1, s = 'new' where rver = 1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> update test set rver = 1, s = 'new' where rver = 17;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

mysql> update test set rver = 1, s = 'neww' where rver = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Thanks,
Chris




More information about the Python-list mailing list