Search code examples
pythonsql-serverdatabaseodbcpyodbc

Pyodbc: Unable to update table on database (no error)


I have:

import pyodbc
con_str = "DRIVER={%s};SERVER=%s;UID=%s;PWD=%s;DATABASE=%s" % \
          ('FreeTDS','192.168.1.22','myuser','mypass','mydb')
con = pyodbc.connect(con_str)
cur = con.cursor()
cur.execute("update mytable set name='abcd'")
con.commit()
con.close()

The code executes and exits without any error !

But the database remains unchanged - nothing happened.


Solution

  • Resolved..

    The problem was in the FreeTDS driver that I used. I ran the same script on a windows machine using its native SQL Server Native Client 10.0 driver.

    And it worked GREAT !