python - Pyodbc 错误 - Python 到 MS Access

标签 python ms-access odbc pyodbc

我在 Windows 7、Python 2.7 和 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 的问题。我已经执行了以下操作:

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

2) 允许帐户 Access HKEY_LOCAL_MACHINE\SOFTWARE\ODBC 注册表项

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

Error in opening an Access database in python

"General error Unable to open registry key Temporary (volatile) ..." from Access ODBC

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

4) 当我尝试运行这段代码时,Access 数据库没有打开。我已重新启动计算机,但仍收到此错误。

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

最佳答案

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

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

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

关于python - Pyodbc 错误 - Python 到 MS Access,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36180703/

相关文章:

python - 检测 Django 函数是否正在 celery worker 中运行

java - 表达式不在聚合或 GROUP BY 列中异常

c# - 如何在 Filemaker 数据库中通过 ODBC 查询布局

sql-server - SQL Server 错误 "String Data, Right Truncation"是什么意思以及如何修复它?

mysql - 使用 MySQL 作为 Metastore 从 HIVE 查询元数据

python - 用自定义激活替换 sigmoid 激活

python - python 中的 Apache Beam : How to reuse exactly the same transform on another PCollection

python - 安装 gruobipy 包 - 错误

sql - 如何在表和查询上使用 SELECT 插入

sql - ORDER BY 无法 Access