Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

Pyodbc Update SQL Server script not updating

$
0
0

I am trying to run a simple SQL Server update script through Python pyodbc but when executing the python script, it's not making the update for some reason and I can't find the cause as it does not give any error message either. Below is my code sample:

import pyodbccnxn = pyodbc.connect("Driver=X;""Server=X;""Database=X;""UID=X;""PWD=X;""trusted_connection=yes;")cursor = cnxn.cursor()script = """    ;with cte as (        SELECT ID FROM table1        WHERE column1 IS NOT NULL    )    UPDATE table2    SET column2 = 'value'    WHERE column3 IN (SELECT ID FROM cte)"""cursor.execute(script)cnxn.commit()cursor.close()cnxn.close()

Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>