Saya mencoba menyambung ke SQL melalui python untuk menjalankan beberapa kueri pada beberapa database SQL di server Microsoft SQL. Dari penelitian saya secara online dan di forum ini perpustakaan yang paling menjanjikan tampaknya adalah pyodbc. Jadi saya telah membuat kode berikut
import pyodbc
conn = pyodbc.connect(init_string="driver={SQLOLEDB}; server=+ServerName+;
database=+MSQLDatabase+; trusted_connection=true")
cursor = conn.cursor()
dan dapatkan error berikut
Traceback (most recent call last):
File "C:\Users...\scrap.py", line 3, in <module>
conn = pyodbc.connect(init_string="driver={SQLOLEDB}; server=+ServerName+; database=+MSQLDatabase+; trusted_connection=true")
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
I have looked at the folowing posts and tried changing my driver to {sql server} and have connected using ODBC links before in SAS, which is partially what my above code is based on, so don't think I need to install anything else.
Pyodbc - "Data source name not found, and no default driver specified"
Thanks