Here's what I've tried:
这是我尝试过的:
-Find Vista's ODBC Data Source Manager* through search,
- 通过搜索找到Vista的ODBC数据源管理器*
-Add a new File Data Source*, selecting Driver for Microsoft Access (*.mdb), and selecting my mdb file of interest,
- 添加新的文件数据源*,选择Microsoft Access驱动程序(* .mdb),并选择我感兴趣的mdb文件,
-import pyodbc from python shell and try:
- 从python shell导入pyodbc并尝试:
pyodbc.connect("DSN=<that Data Source I just created>")
I get the following error message (Portuguese**):
我收到以下错误消息(葡萄牙语**):
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Nome da fonte de dados n\xe3o encontrado e nenhum driver padr\xe3o especificado (0) (SQLDriverConnectW)')
Which translates as "Data source name not found and no standard driver specified".
其中翻译为“未找到数据源名称且未指定标准驱动程序”。
What am I doing wrong? How to get it right? Also, I searched the web for documentation but found nothing worth much, could anyone recommend any documentation?
我究竟做错了什么?如何做到对了?此外,我搜索了网络上的文档,但发现没有什么值得,任何人都可以推荐任何文档?
*Names may not be completely accurate because my Windows is in Portuguese.
*名称可能不完全准确,因为我的Windows是葡萄牙语。
**No, Portuguese doesn't have '3' and '\' as letters, these are misprinted special characters
**不,葡萄牙语没有'3'和'\'作为字母,这些都是错误印刷的特殊字符
4 个解决方案
#1
6
DSN= is only used for a system or user DSN.
DSN =仅用于系统或用户DSN。
For a DSN File, you need to use FILEDSN=c:\myDsnFile.dsn
对于DSN文件,您需要使用FILEDSN = c:\ myDsnFile.dsn
http://www.connectionstrings.com/ is your best friend.
http://www.connectionstrings.com/是你最好的朋友。
#2
2
I had a similar problem with pyodbc although not with Access but a different ODBC driver.
虽然不是使用Access而是使用不同的ODBC驱动程序,但我遇到了与pyodbc类似的问题。
This is what helped me. http://robertoschiabel.wordpress.com/2008/02/28/windows-x64-32bit-odbc-vs-64bit-odbc/ (here is the appropriate KB article in case this URL goes away. http://support.microsoft.com/kb/942976/en-us )
这对我有所帮助。 http://robertoschiabel.wordpress.com/2008/02/28/windows-x64-32bit-odbc-vs-64bit-odbc/(如果此URL消失,这里是相应的知识库文章.http:// support。 microsoft.com/kb/942976/en-us)
Our previous server hardware died and we had to quickly redeploy on a 64 bit OS because that is all we had that was available. Using the normal ODBC admin tool I added the appropriately named DSN but it still claimed it wasn't found. Only when running the special 32-bit version of the ODBC admin, was I able to define a DSN that my script using pyodbc could find.
我们之前的服务器硬件已经死亡,我们不得不在64位操作系统上快速重新部署,因为这就是我们所拥有的所有功能。使用普通的ODBC管理工具,我添加了适当命名的DSN,但它仍然声称找不到它。只有在运行特殊的32位版本的ODBC管理员时,才能定义我的脚本使用pyodbc可以找到的DSN。
#3
1
I use odbc
module (included in ActiveState Python), but tested pyodbc
and for me works:
我使用odbc模块(包含在ActiveState Python中),但测试了pyodbc并且对我有用:
#db = odbc.odbc('northwind')
#db = odbc.odbc('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
#db = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
db = pyodbc.connect('DSN=northwind')
Of course commented connections works too.
当然评论的连接也有效。
I configured nothwind
as user DSN so you probably will have to configure your ODBC database connection as User DSN or System DSN, or without configuring in ODBC Administrator you can use ConnectString where you can point at your .mdb
file.
我将nothwind配置为用户DSN,因此您可能必须将ODBC数据库连接配置为用户DSN或系统DSN,或者无需在ODBC管理器中进行配置,您可以使用ConnectString指向.mdb文件。
#4
1
It's smart to list your odbc connections with pyodbc to see what are you using. Make sure you use appropriate pyodbc 32 bit Python 32 bit driver. If you want to use 64bit access files you should use 64 bit MS Acceess which provides driver.
用pyodbc列出你的odbc连接是很明智的,看看你在用什么。确保使用适当的pyodbc 32位Python 32位驱动程序。如果要使用64位访问文件,则应使用提供驱动程序的64位MS Acceess。
sources = pyodbc.dataSources()
keys = sources.keys()
for key in keys:
print key
#1
6
DSN= is only used for a system or user DSN.
DSN =仅用于系统或用户DSN。
For a DSN File, you need to use FILEDSN=c:\myDsnFile.dsn
对于DSN文件,您需要使用FILEDSN = c:\ myDsnFile.dsn
http://www.connectionstrings.com/ is your best friend.
http://www.connectionstrings.com/是你最好的朋友。
#2
2
I had a similar problem with pyodbc although not with Access but a different ODBC driver.
虽然不是使用Access而是使用不同的ODBC驱动程序,但我遇到了与pyodbc类似的问题。
This is what helped me. http://robertoschiabel.wordpress.com/2008/02/28/windows-x64-32bit-odbc-vs-64bit-odbc/ (here is the appropriate KB article in case this URL goes away. http://support.microsoft.com/kb/942976/en-us )
这对我有所帮助。 http://robertoschiabel.wordpress.com/2008/02/28/windows-x64-32bit-odbc-vs-64bit-odbc/(如果此URL消失,这里是相应的知识库文章.http:// support。 microsoft.com/kb/942976/en-us)
Our previous server hardware died and we had to quickly redeploy on a 64 bit OS because that is all we had that was available. Using the normal ODBC admin tool I added the appropriately named DSN but it still claimed it wasn't found. Only when running the special 32-bit version of the ODBC admin, was I able to define a DSN that my script using pyodbc could find.
我们之前的服务器硬件已经死亡,我们不得不在64位操作系统上快速重新部署,因为这就是我们所拥有的所有功能。使用普通的ODBC管理工具,我添加了适当命名的DSN,但它仍然声称找不到它。只有在运行特殊的32位版本的ODBC管理员时,才能定义我的脚本使用pyodbc可以找到的DSN。
#3
1
I use odbc
module (included in ActiveState Python), but tested pyodbc
and for me works:
我使用odbc模块(包含在ActiveState Python中),但测试了pyodbc并且对我有用:
#db = odbc.odbc('northwind')
#db = odbc.odbc('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
#db = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=Nwind.mdb;Uid=;Pwd=;')
db = pyodbc.connect('DSN=northwind')
Of course commented connections works too.
当然评论的连接也有效。
I configured nothwind
as user DSN so you probably will have to configure your ODBC database connection as User DSN or System DSN, or without configuring in ODBC Administrator you can use ConnectString where you can point at your .mdb
file.
我将nothwind配置为用户DSN,因此您可能必须将ODBC数据库连接配置为用户DSN或系统DSN,或者无需在ODBC管理器中进行配置,您可以使用ConnectString指向.mdb文件。
#4
1
It's smart to list your odbc connections with pyodbc to see what are you using. Make sure you use appropriate pyodbc 32 bit Python 32 bit driver. If you want to use 64bit access files you should use 64 bit MS Acceess which provides driver.
用pyodbc列出你的odbc连接是很明智的,看看你在用什么。确保使用适当的pyodbc 32位Python 32位驱动程序。如果要使用64位访问文件,则应使用提供驱动程序的64位MS Acceess。
sources = pyodbc.dataSources()
keys = sources.keys()
for key in keys:
print key