Python Forum

Full Version: Connection to MS SQL Database not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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