July 31st, 2004, 07:43 AM
mysql affected rows
how can I learn affected rows after a query with python ?
I am using MySQLdb for included. does it support the function which like mysql_affected_rows like php ?
August 1st, 2004, 07:27 AM
Yes, there's a method called affectedrows() which should do what you want. You can see an example/semi-explanation of this here.
Hope this helps,
August 2nd, 2004, 05:18 AM
it doesn't work
thank you mark,
but the sample for python 1.5.1 and I am using 2.3.4
accessing mysql in the sample is very well for me .
because it like php
importing mysql begin of the code, not mysqldb.
this mysql module is different from mysqldb or it is old version of mysqldb.
August 2nd, 2004, 09:24 AM
Sorry, i hadnt expected them to change the interface . Silly me. Anyway, this page: http://phplens.com/lens/adodb/adodb-py-docs.htm seems to think that you can use th Affected_Rows() method. Wether or not this is true i dont know.
Ill install MySQLdb and let you know. I really need to learn how to build MySQL on Unix anyway .
August 2nd, 2004, 11:07 AM
Ok, scratch that. After installing MySQL 4.0.20 and MySQLdb 1.0.0 on my IBook you can clearly see that the method is called affected_rows()... Which prompts me to say, STOP changing the name guys .
So in theory that should do it .
August 3rd, 2004, 03:13 AM
I tried it yesterday but I couldn't find affected_rows function
because I guess I should be try to dir(result)
but I have to check dir(connection)
whatever, I write script to help me.
it works like that,
it take functions about a value and docs and write to screen with for ,
aa = dir(value)
for a in aa:
print a, "\n help : \n", a.__doc__ , "\n\n"
something like that.
I can see which functions I can use with my variables.
but I dont know yet how can I add this script to under site-packages
if I can add a python module, I can call it everytime when I need it like a function.
thanks again, mohikan
August 3rd, 2004, 12:13 PM
Im a little comfused, nothing new there . It is working though right?
If you want to add a script to site-packages just save the file and move it into the site-packages directory. You should then be able to import it without any problems.