Accessing a local SQL Server 2008 database with pyodbc on Windows 7

假如想象 提交于 2019-12-10 17:41:22

问题


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)')

Trying to connect via Windows authentication (with 'Trusted_Connection=yes') fails as well.

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?


回答1:


Reinstalling SQL Server did the trick



来源:https://stackoverflow.com/questions/11810681/accessing-a-local-sql-server-2008-database-with-pyodbc-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!