MYSQLDB python module
I am using MySQLdb module of python on FC11 machine. Here, i have an issue. I have the following implementation for one of our requirement:
- connect to mysqldb and get DB handle,open a cursor, execute a delete statement,commit and then close 开发者_StackOverflowthe cursor.
- Again using the DB handle above, iam performing a "select" statement one some different table using the cursor way as described above.
I was able to delete few records using Step1, but step2 select is not working. It simply gives no records for step2 though there are some records available under DB.
But, when i comment step1 and execute step2, i could see that step2 works fine. Why this is so?
Though there are records, why the above sequence is failing to do so? Any ideas would be appreciated.
Thanks!
With no code, I can only make a guess: try not closing the cursor until you are done with that connection. I think that calling cursor() again after calling cursor.close() will just give you a reference to the same cursor, which can no longer be used for queries.
I am not 100% sure if that is the intended behavior, but I haven't seen any MySQLDB examples of cursors being opened and closed within the same connection.
It sounds as though the first cursor is being returned back to the second step.
did u try
records = cur.fetchall()
?
精彩评论