Pyodbc 错误 - Python 到 MS Access [英] Pyodbc Error - Python to MS Access

查看:132
本文介绍了Pyodbc 错误 - Python 到 MS Access的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 7、Python 2.7 和 Microsoft Access 2013 上运行.

I am running on Windows 7, Python 2.7 and Microsoft Access 2013.

当我尝试跑步时:

import pyodbc
conn_string = '''
DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};
UID=admin;
UserCommitSync=Yes;
Threads=3;
SafeTransactions=0;
PageTimeout=5;
MaxScanRows=8;
MaxBufferSize=2048;
FIL=MS Access;
DriverId=25;
DefaultDir=C:\Users\jseinfeld;
DBQ=C:\Users\jseinfeld\Desktop\Databasetest1.accdb;
'''
connection = pyodbc.connect(conn_string)

我收到以下错误消息:

Error: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x29dc Thread 0x113c DBC 0x8a3ed48    

Jet'. (63) (SQLDriverConnect); [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x29dc Thread 0x113c DBC 0x8a3ed48

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 0x29dc Thread 0x113c DBC 0x8a3ed48 

Jet'. (63); [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x29dc Thread 0x113c DBC 0x8a3ed48

Jet'. (63); [HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044)")

我意识到有很多关于 Pyodbc 和 MS Access 的问题.我已经执行了以下操作:

I realize there are many questions regarding Pyodbc and MS Access. I have already executed the following:

1) 确保我有 64 位 Python 和 64 位 MS Access

1) Ensured I have 64 bit Python and 64 bit MS Access

2) 授予帐户访问 HKEY_LOCAL_MACHINE\SOFTWARE\ODBC 注册表项的权限

2) Given permission to the account access to the HKEY_LOCAL_MACHINE\SOFTWARE\ODBC registry key

https://support.microsoft.com/en-us/kb/295297

在 python 中打开 Access 数据库时出错

"一般错误无法打开注册表项临时(易失性)..."从访问 ODBC

3) 试图确保我有一个有效的连接字符串 https://stackoverflow.com/questions/6469545/python-connecting-to-a-database-with-pyodbc-not-working#=

3) Tried to ensure I have a valid connection string https://stackoverflow.com/questions/6469545/python-connecting-to-a-database-with-pyodbc-not-working#=

4) 当我尝试运行此代码时,Access 数据库未打开.我已经重新启动了我的计算机,但仍然收到此错误.

4) The Access database is not open when I try running this code. I have re-booted my computer and am still receiving this error.

如果我可以尝试其他任何操作,请告诉我.

Please let me know if there is any other action I can try.

推荐答案

从一个只有 DRIVERDBQ 属性且没有嵌入换行符的简单连接字符串开始...

Start with a simple connection string with only the DRIVER and DBQ attributes and no embedded line breaks ...

conn_string = r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\jseinfeld\Desktop\Databasetest1.accdb;'

一旦您获得最简单的连接字符串,您就可以根据需要添加和测试其他连接属性.

Once you get the simplest connection string working, you can add and test other connection attributes as needed.

这篇关于Pyodbc 错误 - Python 到 MS Access的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆