S
Sheila King
I have searched for an answer to this question on the comp.lang.python
archives at Google Groups, and also looked through the (sparse) MySQLdb
documentation, and cannot confirm for a FACT what I think I know.
Looking for affirmation before I go "assuming" something and getting myself
into trouble somewhere along the line...
Here is what I *think* I know...let me know if I'm wrong, for crying out
loud!!!
If I do something like:
and then later do:
doesn't result always return the number of affected rows?
As a more concrete example:
I made the following table:
mysql> CREATE TABLE example(
-> name VARCHAR(14),
-> AGE INT,
-> COUNTRY VARCHAR(15));
Query OK, 0 rows affected (0.03 sec)
And then in Python did the following INSERTS and UPDATE:
2L
Can I *RELY* on that "2L" result of the UPDATE statement under the cursor's
"execute" method representing the number of rows updated? Or am I assuming
too much?
Like I say, I looked through several sources, including my O'Reilly MySQL
book and cannot verify this for a fact from docs.
I did find this, however:
http://www.mysql.com/doc/en/UPDATE.html
"UPDATE returns the number of rows that were actually changed. In MySQL
Version 3.22 or later, the C API function mysql_info() returns the number
of rows that were matched and updated and the number of warnings that
occurred during the UPDATE. "
Which seems to corroborate, although they are not referring to the Python
DB-API specifically.
Thanks for any clarification on this matter,
archives at Google Groups, and also looked through the (sparse) MySQLdb
documentation, and cannot confirm for a FACT what I think I know.
Looking for affirmation before I go "assuming" something and getting myself
into trouble somewhere along the line...
Here is what I *think* I know...let me know if I'm wrong, for crying out
loud!!!
If I do something like:
and then later do:
doesn't result always return the number of affected rows?
As a more concrete example:
I made the following table:
mysql> CREATE TABLE example(
-> name VARCHAR(14),
-> AGE INT,
-> COUNTRY VARCHAR(15));
Query OK, 0 rows affected (0.03 sec)
And then in Python did the following INSERTS and UPDATE:
2L
Can I *RELY* on that "2L" result of the UPDATE statement under the cursor's
"execute" method representing the number of rows updated? Or am I assuming
too much?
Like I say, I looked through several sources, including my O'Reilly MySQL
book and cannot verify this for a fact from docs.
I did find this, however:
http://www.mysql.com/doc/en/UPDATE.html
"UPDATE returns the number of rows that were actually changed. In MySQL
Version 3.22 or later, the C API function mysql_info() returns the number
of rows that were matched and updated and the number of warnings that
occurred during the UPDATE. "
Which seems to corroborate, although they are not referring to the Python
DB-API specifically.
Thanks for any clarification on this matter,