问题
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