0

I am trying to connect to SQL Server using Python's pyodbc. What I have is

conn= pyodbc.connect('Driver ={SQL server Native Client 19.0};'
                          'Server = ('my server name;'
                          'Database ='my database name;'
                          'Trusted_Connection = yes;')

But I get:

pyodbc.InterfaceError: ('IM002, '[IM002][Driver Manager] Data source name not found and no default driver specified(0)(SQLDriverConnect).

Not sure how to correct it?

Dale K
  • 25,246
  • 15
  • 42
  • 71
PChao
  • 417
  • 2
  • 5
  • 17
  • 1
    FWIW I've never seen mention of an ODBC driver named `SQL server Native Client 19.0`. `SQL Server Native Client 11.0` is the newest one that *I've* seen .... Also, those round brackets do not belong in a connection string. – Gord Thompson Aug 28 '21 at 23:35
  • To add: the [Native Client](https://learn.microsoft.com/en-us/sql/relational-databases/native-client/sql-server-native-client?view=sql-server-ver15) is deprecated per MSDN docs. 11.0 unsupported after SQL Server 2014. – Parfait Aug 29 '21 at 02:21

1 Answers1

0

Try removing the space after "Driver"; make it "Driver=" as spaces can sometimes be the cause of issues when handling SQL as pointed out by the top answer in the other question with the same error message as you. If this does not work, try looking at the answers on this question to solve your issue.

Initial Answer (redundant as points out typo that exists only on StackOverflow): You have a typo. Do Ctrl + F and find "Databasde" to find your typo. Change this to Database.

Your program is finding a database called "Databasde" instead of "Database", as this is what you have technically told it to do.

Disclaimer:

I work entirely with SQLite3 as I find it much easier to use so I'm not 100% certain on what's causing the problem, but I do know that the syntax looks weird in comparisons to a similar question.

  • sorry that is my type. thanks for point that out. I made that type during the asking of the question. what I have in the actual script is Databse = .....' – PChao Aug 28 '21 at 23:25
  • @PChao I've edited my answer with a possible solution for you. I hope it helps. – TheAngriestCrusader Aug 28 '21 at 23:36