I'm attempting to connect my SQL Server database to python using this documentation as a guide. https://www.mssqltips.com/sqlservertip/7293/pyodbc-open-source-access-odbc-databases/.
I am running into an issue with the driver where I keep getting this error message:
> Traceback (most recent call last): File
> "c:\Users\Diane\Documents\ProjectDB.py", line 3, in <module>
> conn = pyodbc.connect('DRIVER= {ODBC Driver 18 for SQL Server}; \
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 18
> for SQL Server]Named Pipes Provider: Could not open a connection to
> SQL Server [53]. (53) (SQLDriverConnect); [08001] [Microsoft][ODBC
> Driver 18 for SQL Server]Login timeout expired (0); [08001]
> [Microsoft][ODBC Driver 18 for SQL Server]Invalid connection string
> attribute (0); [08001] [Microsoft][ODBC Driver 18 for SQL Server]A
> network-related or instance-specific error has occurred while
> establishing a connection to MSSQLLocalDB. Server is not found or not
> accessible. Check if instance name is correct and if SQL Server is
> configured to allow remote connections. For more information see SQL
> Server Books Online. (53)')
I am currently using this script:
import pyodbc
conn = pyodbc.connect('DRIVER= {ODBC Driver 18 for SQL Server}; \
SERVER=MSSQLLocalDB; \
DATABASE=Christopher_Kirkwood_DB; \
Trust_Connection=yes')
I have also have downloaded the driver provided here : https://learn.microsoft.com/en-us/sql/connect/odbc/windows/release-notes-odbc-sql-server-windows?view=sql-server-ver15
I have tried opening odbc and checked the configuration settings like the error suggests but haven't found anything that fixes my issue.