SQL Update statement but using pyodbc

你。 提交于 2019-12-05 02:41:29

You can execute an UPDATE statement just as you now execute your INSERT:

    cnxn = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=C:\\Users\\...............(file location)')
    cursor = cnxn.cursor()
    cursor.execute("UPDATE progress SET CockpitDrill = ? WHERE progress_primarykey = ?", newcockpitdrillvalue, oldprimarykeyvalue)
    cnxn.commit()

Does that help? "progress_primarykey" is the assumed name I've given to the primary key field in your database table. That's supposing you just want to change one record and you know its primary key.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!