0

How to overcome below error while connecting to MS-SQL Server through python using pyodbc module ??

Traceback (most recent call last):
  File "test_db.py", line 2, in <module>
    cnxn = pyodbc.connect(r'Driver={SQL Server};Server=.\ITRES-PRD-SQL-1;Database=testdb;Trusted_Connection=yes;')
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')
HaRsHu
  • 43
  • 1
  • 6
  • Possible duplicate of [Pyodbc - "Data source name not found, and no default driver specified"](http://stackoverflow.com/questions/16280304/pyodbc-data-source-name-not-found-and-no-default-driver-specified) –  Feb 11 '16 at 11:57
  • Try it with all caps keys: `cnxn = pyodbc.connect(r'DRIVER={SQL Server};SERVER=.\\ITRES-PRD-SQL-1;DATABASE=testdb;Trusted_Connection=yes;')`. Don't forget to escape the backslash in your instance name too. – apex-meme-lord Feb 11 '16 at 13:16
  • What driver are you using under the hood? FreeTDS or MSODBC? – FlipperPA Feb 11 '16 at 20:24
  • I found pymssql is the best and simple module for connecting to mssql through python. – HaRsHu Feb 22 '16 at 10:23

0 Answers0