ODBC错误Unable to open registry key Temporary (volatile) Ace DSN for process

python的pyodbc与nodejs的odbc链接accdb数据时,connectionString使用

Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=test.accdb

pyodbc抛出错误

pyodbc.Error: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x3894 Thread 0x167c DBC 0x5bf399e8 Jet'. (63) (SQLDriverConnect);
[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x3894 Thread 0x167c DBC 0x5bf399e8 Jet'. (63); 
[HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044); [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x3894 Thread 0x167c DBC 0x5bf399e8 Jet'. (63); 
[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x3894 Thread 0x167c DBC 0x5bf399e8 Jet'. (63); 
[HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044)")

node抛出错误

(node:16948) UnhandledPromiseRejectionWarning: Error: [odbc] Error connecting to the database
(node:16948) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16948) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

就算connectionString使用(*.mdb)的结果也是一样。使用ProcessMoniter跟踪python和node,发现它们总在读取

HKCU\SOFTWARE\ODBC\ODBC.INI\\Engines\Jet
HKLM\Software\Microsoft\Office\16.0\Access Connectivity Engine\Engines\Jet

估计是本机系统使用windows 10 x64,MDAC 2.8只支持x86,而JET引擎已被ACE引擎替换,pyodbc与node-odbc开发之时,估计仍然采用基于JET的SDK,而使用ADODB.Connection没有这个问题,查看注册表,所有微软的office ODBC驱动全部指向

C:\Program Files\Common Files\Microsoft Shared\OFFICE16\ACEODBC.dll

当然这是猜测,网上python有用odbc链接accdb的例子,运行系统是x86还是x64就不知道,有空装个x86的虚拟机测试一下。

PS:今天有空,装了个x86的虚拟机,这次连ADO也不管用了,跟踪程序N次,发现很多注册表Access Denied提示,于是用管理员权限运行脚本,发现最终抛出Not a valid file name错误,于是用数据库绝对路径,这次OK了,所有python和node的程序都OK了。

Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=test.accdb

改成

Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:\www\test.accdb

就行。或者DBQ=./test.accdb也可以。很是无语。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值