在 Windows 7 上使用 pyodbc 访问本地 SQL Server 2008 数据库 [英] Accessing a local SQL Server 2008 database with pyodbc on Windows 7
问题描述
我正在尝试使用 pyodbc 连接到 SQL Server 2008 数据库的本地副本(它可以很好地连接到远程生产数据库).
I'm trying to use pyodbc to connect to a local copy of a SQL Server 2008 database (it connects to the remote production database just fine).
但是,当我尝试使用以下命令连接到本地副本时:
However, when I try connecting to the local copy using the following command:
pyodbc.connect('DRIVER={SQL
Server};SERVER=localhost;DATABASE=mydb;UID=me;PWD=pw')
连接失败并显示以下错误消息:
the connection fails with the following error message:
pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server
Driver][DBNETLIB]SQL Server does not exist or access denied. (17)
(SQLDriverConnect); [01000] [Microsoft][ODBC SQL Server
Driver][DBNETLIB]ConnectionOpen (Connect()). (5)')
尝试通过 Windows 身份验证(使用 'Trusted_Connection=yes'
)连接也失败.
Trying to connect via Windows authentication (with 'Trusted_Connection=yes'
) fails as well.
我可以使用带有 Windows 身份验证和 SQL Server 身份验证的 SQL Server Management Studio 正常连接到本地数据库.为什么我无法与 pyodbc 连接的任何想法?
I can connect to the local database fine using SQL Server Management Studio with both Windows Authentication and SQL Server Authentication. Any ideas why I can't connect with pyodbc?
推荐答案
重新安装 SQL Server 成功
Reinstalling SQL Server did the trick
这篇关于在 Windows 7 上使用 pyodbc 访问本地 SQL Server 2008 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!