This is really stupid, but I just wasted about an hour of dev time trying to figure out why my INSERT statements weren't working from a Python script using pyodbc even though SELECTs were fine. As it turns out, they were getting rolled back because I wasn't explicitly committing the transactions and hadn't set the AUTOCOMMIT option to true for the connection.
So if you happen to search for "pyodbc INSERT problems" (as I did), hopefully you'll stumble across this (as opposed to nothing, which is what I found) and slap yourself in the head (as I did).
Monday, March 10, 2008
Subscribe to:
Post Comments (Atom)
7 comments:
Thanks, this was useful. I ran into the same problem.
Thanks :) Pretty nice Google rank, BTW.
thanks for this.
thanks, so good
uh thanks for showing us the code
Seriously, Robert? pyodbc.connect() has a pretty simple signature.
But in the interest of completeness, here you go:
pyodbc.connect('DSN=test', autocommit=True)
Post a Comment