PYODBC--Data source name not found and no default driver specified

后端 未结 15 1654
暖寄归人
暖寄归人 2020-11-28 13:01
import pyodbc
connection = pyodbc.connect(\'Driver = {SQL Server};Server=SIWSQL43A\\SIMSSPROD43A;\'
                            \'Database=CSM_reporting;Trusted_Conn         


        
相关标签:
15条回答
  • 2020-11-28 13:26

    I've met same problem and fixed it changing connection string like below. Write

    'DRIVER={ODBC Driver 13 for SQL Server}'
    

    instead of

    'DRIVER={SQL Server}'
    
    0 讨论(0)
  • 2020-11-28 13:27

    Below connection string is working

    import pandas as pd
    import pyodbc as odbc
    
    sql_conn = odbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER=SERVER_NAME;DATABASE=DATABASE_NAME;UID=USERNAME;PWD=PASSWORD;')
    
    query = "SELECT * FROM admin.TABLE_NAME"
    df = pd.read_sql(query, sql_conn)
    df.head()
    
    0 讨论(0)
  • 2020-11-28 13:32

    Have you installed any product of SQL in your system machine ? You can download and install "ODBC Driver 13(or any version) for SQL Server" and try to run if you havent alerady done.

    0 讨论(0)
提交回复
热议问题