Python Forum
Connection to MS SQL Database not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connection to MS SQL Database not working
#1
I am new to python (ex VBA programmer). I get the error message when trying to connect

[MICROSOFT ODBC DRIVER] Data source name not found and no defualt driver specified.

i am using the following code.

import pyodbc
con = pyodbc.connect("Driver{ODBC Driver 10 for SQL Server};"
"Server=UK171768;"
"Database=PYTHON1;"
"Trusted_Connection=yes;")

cur=con.cursor()
cur.execute('SELECT * FROM dbo.tbl_Customers')
in VBA i can connect using:

sconnect = "Provider=SQLNCLI10; Server=uk171768; Database=PYTHON1; Trusted_Connection=YES;"

any ideaS?
Reply
#2
It looks like you are missing = after Driver on line#2
https://github.com/mkleehammer/pyodbc/wi...om-Windows
by the way, just FYI, I'm using pymssql to work with MSSQL DB
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Database connection problems [login, PyQt5, PySql] gradlon93 5 739 Dec-15-2023, 05:08 PM
Last Post: deanhystad
  pysql connection to cloud server database times out Pedroski55 9 4,796 Oct-11-2021, 10:34 PM
Last Post: Pedroski55
  Serial connection connection issue Joni_Engr 15 8,183 Aug-30-2021, 04:46 PM
Last Post: deanhystad
  Connection DATABASE to Python MenThoLLt 3 2,456 Jan-17-2020, 10:35 PM
Last Post: DT2000
  Error in running MS Access Database connection code pyuser1 4 7,721 Feb-01-2018, 08:28 PM
Last Post: pyuser1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020