Search code examples
pythonsql-serverpymssql

pymssql UPDATE statement with temp table


I'm using pymssql and Python 3.6 to update multiple rows with one query on a SQL Server 2019 database.

I use the following query (from https://stackoverflow.com/a/16932591/1046299) :

UPDATE e
SET hire_date = t.hire_date
FROM dbo.employee e
JOIN (
    VALUES
        ('PMA42628M', '1979-03-15'),
        ('PSA89086M', '1988-12-22')
) t (emp_id, hire_date) ON t.emp_id = e.emp_id

However, when I run db_cur.execute(sql_query) then db_conn.commit() the table is not updated. When I run the query in SQL Server, all is good.


Solution

  • Found the solution on this post: pymssql ( python module ) unable to use temporary tables

    I upgraded my version of pymssql and it worked.