0

我曾经pyodbc.executemany在数据库表中插入项目。我正在尝试使用更新多行pyodbc.executemany,但我不断收到错误。是否可以pyodbc.executemany用于更新多行?

这是我的代码:

import pyodbc
import os
listTest=[('okAa','a'),('OKBb','b')]

queryToTest="UPDATE AllTrasactions2 SET [Barcode]=? WHERE [Location]=?"
strForDB = os.getcwd() + '\DBINFO.txt'
openDBFile = open(strForDB, 'r')
currentDirForDB = openDBFile.read()
dbPath = currentDirForDB

con = pyodbc.connect(dbPath)
cur = con.cursor()
cur.executemany(queryToTest,listTest)
con.commit()

这是我的错误:

Traceback (most recent call last):
  File "C:/Users/Test/test.py", line 13, in <module>
    cur.executemany(queryToTest,listTest)
pyodbc.ProgrammingError: ('42S02', "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'AllTrasactions2'. (208) (SQLExecDirectW); [42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")

4

0 回答 0