由于某些原因,我在尝试运行以下代码时不断出错:
pyodbc。错误:('HYC00','[HYC00][Microsoft][ODBC Microsoft Access Driver]可选功能未实现(106)(SQLBindParameter)')
我已经使用pyodbc
很多次了,以前从未遇到过这个问题。我尝试过在没有params
的情况下通过在sql
字符串中显式包含参数来进行此查询,但我也遇到了同样的问题。我使用的是Python 3.3,并且连接到一个MS Access.mdb文件。
record = ('1AC401', 'CAB 1', 'OTSG 1 ROOM', 5, 8, 'CD14-PT-05', 'WFB FDWTR WARMING')
cabling_id = '1AC401/CAB 1/OTSG 1 ROOM'
sql = 'UPDATE [CIOC_DATA] SET [charm_enabled] = ?, '
'[device_tag] = ?, '
'[charm_description] = ?, '
'[charm_cabling_id] = ?, '
'WHERE [charm_baseplate] = ? '
'AND [charm_Address] = ?'
params = ("T", record[5], record[6], cabling_id, record[3], record[4])
cursor.execute(sql, params)
cursor.commit()
更新-我添加了回溯:
Traceback (most recent call last):
File "C:Users*****DocumentsProjects******_******** *** UpgradeNoEvernotepopulateBulkEdit.py", line 48, in <module>
cursor.execute(sql, params)
pyodbc.Error: ('HYC00', '[HYC00] [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented (106) (SQLBindParameter)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:Users******DocumentsProjects******_******** *** UpgradeNoEvernotepopulateBulkEdit.py", line 52, in <module>
+ ': ' + e.args + 'n' )
TypeError: Can't convert 'tuple' object to str implicitly
更新2
TypeError与根本问题无关。这是我错误处理代码的一个次要错误。只关注平壤。上面的代码摘录中有错误。
我猜您传递的这些参数中有一个是元组,而不是字符串。也许是地址。