且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL 更新语句但使用 pyodbc

更新时间:2023-02-03 07:49:37

您可以像现在执行 INSERT 一样执行 UPDATE 语句:

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()

这有帮助吗?progress_primarykey"是我为您的数据库表中的主键字段提供的假定名称.那是假设您只想更改一条记录并且您知道它的主键.

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.