mysqldb problem | update query not working

I had a problem executing an update query. I was using MySQLdb to deal with MySQL from Python. If the query runs successfully then cursor.execute() returns 1. So, I used a print statement and it printed 1, but when I checked the table in mysql database using phpmyadmin, I couldn't see the update in the table.

print cursor.execute("UPDATE products SET category = %s WHERE upc = %s", (category, upc))


Then I Googled for a few minutes and found this link: http://stackoverflow.com/questions/1028671/python-mysqldb-update-query-fails

So, the solution I used is the following:

conn.autocommit(True)

Comments

Popular posts from this blog

Strip HTML tags using Python

lambda magic to find prime numbers

Convert text to ASCII and ASCII to text - Python code