Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python SQL update query: string or integer address expected instead of instance instance

I use Python 2.7 and pypyodbc in order to run SQL queries but whenever I run the update query using python,

cursor.execute("UPDATE tbl_User SET gender = ? WHERE id = 1", ['male'])

I get the error:

TypeError: string or integer address expected instead of instance instance

The same query works if I run it directly on SQL Server.

like image 542
Shani Gamrian Avatar asked Aug 05 '26 18:08

Shani Gamrian


1 Answers

The problem was I didn't put a semicolon at the end of the query. The solution is:

cursor.execute("UPDATE tbl_User SET gender = ? WHERE id = 1;", ['male'])
like image 110
Shani Gamrian Avatar answered Aug 08 '26 10:08

Shani Gamrian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!