Hi all! HELP! : )
I'm able to read rows from SQL Server just fine with pyodbc, but I can't seem to update a row. Any ideas? At this point there's no gis involvement here, but there will be once I can modify the table.
import pyodbc
cstring = 'DRIVER={SQL Server};SERVER=aServer;DATABASE=aDatabase;UID=aUN;PWD=aPassword'
con = pyodbc.connect(cstring)
cur = con.cursor()
sql = """UPDATE Stats SET myColumn = 'TEST' WHERE case_number = 'case9999'"""
rows = cur.execute(sql).fetchall()
con.commit()
cur.close()
del cur, con
>>>pyodbc.ProgrammingError: No results. Previous SQL was not a query.
Solved! Go to Solution.
The error message says it all. An UPDATE statement doesn’t return rows. You can execute() without calling fetchall().
The error message says it all. An UPDATE statement doesn’t return rows. You can execute() without calling fetchall().
You are the coolest! I normally am only reading these tables, so now I can go have some fun!