Python: using pyodbc and replacing row field values -
Python: using pyodbc and replacing row field values -
i'm trying figure out if it's possible replace record values in microsoft access (either .accdb or .mdb) database using pyodbc. i've poured on documentation , noted says "row values can replaced" have not been able create work.
more specifically, i'm attempting replace row value python variable. i've tried:
setting connection autocommit "true"
made sure it's not info type issue
here snippet of code i'm executing sql query, using fetchone() grab 1 record (i know script query returning 1 record), grabbing existing value field (the field position integer stored in z variable), , getting new value want write field accessing existing python dictionary created in script.
psql = "select * %s %s = '%s'" % (reviewtbl, newid, basinid) cursor.execute(psql) record = cursor.fetchone() if record: oldval = record[z] val = codecrosswalk[oldval] record[z] = val i've tried can think bit cannot work. misunderstanding help documentation?
the script runs newly assigned value never seems commit. tried putting "print str(record[z])this after record[z] = val line see if field in table has new value , new value print worked...but if check in table after script has finished old values still in table field.
much appreciate insight this...i hoping work how using vba in ms access databases can utilize ado recordset loop through records in table , assign values field variable.
thanks, tom
the "row values can replaced" pyodbc documentation refers fact can modify values on returned row objects, illustration perform cleanup or conversion before start using them. not mean these changes automatically persisted in database. have utilize sql update statements that.
python pyodbc
Comments
Post a Comment