'Unable to establish connection to sql-server using pyodbc on Windows 10

import pyodbc as sql
import pandas as pd

source_db_config = {
    'Trusted_Connection': 'yes',
    'driver': '{SQL Server}',
    'server': '.',
    'database': 'AdventureWorksDW2017',
    'autocommit': True,
}


source_connect = sql.connect(**source_db_config)

cannot connect with sql server. It's showing OperationalError:

OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][Shared Memory]SQL Server does not exist or access denied. (17) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server Driver][Shared Memory]ConnectionOpen (Connect()). (2)')

How can I solve this?



Solution 1:[1]

Python required additional driver to be install to get connect with Databases.

In your case download python driver for sql server

https://docs.microsoft.com/en-us/sql/connect/python/python-driver-for-sql-server

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ankit.jbp