Error on Connecting Python code to SQL Server

Python i.c.m. Arduino
Berichten: 1
Geregistreerd: 26 Mei 2021, 19:50
Woonplaats: GB

Error on Connecting Python code to SQL Server

Berichtdoor satineeraj » 26 Mei 2021, 20:07

Hello , I am trying to connect to SQL through python to run some queries on some SQL databases on Microsoft SQL server. From my research online and on this forum the most promising library seems to be pyodbc. So I have made the following code

import pyodbc
conn = pyodbc.connect(init_string="driver={SQLOLEDB}; server=+ServerName+;
database=+MSQLDatabase+; trusted_connection=true")
cursor = conn.cursor()

and i am getting the following error

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)')

Please Help

Advertisement

Berichten: 4064
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: Error on Connecting Python code to SQL Server

Berichtdoor shooter » 26 Mei 2021, 21:40

put this question in a python forum as this is specialised in arduino
paul deelen
shooter@home.nl

Berichten: 287
Geregistreerd: 15 Apr 2021, 20:05

Re: Error on Connecting Python code to SQL Server

Berichtdoor ctunes » 26 Mei 2021, 23:44

satineeraj schreef:Data source name not found and no default driver specified
Please Help


In this case help is unavailable.
You have not defined your helpsource.

Terug naar Python

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 3 gasten