0

I've searched through about 50 posts that have the IM002 error and can't seem to figure out why I'm getting it. The full error is:

Traceback (most recent call last):
  File "crc-upload-touchscreen-email-to-socketlabs.py", line 70, in <module>
    "password =" + password + ";"
pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

I'm using an instance file to insert the relevant information.

here is what I have:

logger.info('Connect to database')
server = config.get('connection', 'server')
dbname = config.get('connection', 'dbname')
user = config.get('connection', 'username')
password = config.get('connection', 'password')
pyodbc.connect("DRIVER = {ODBC Driver 13 for SQL Server};"
    "Server =" + server + ";"
    "Database =" + dbname + ";"
    "username =" + user + ";"
    "password =" + password + ";"
    "Trusted_Connection = yes;")
roganjosh
  • 12,594
  • 4
  • 29
  • 46
E.Ostler
  • 5
  • 6
  • Could be helpful https://stackoverflow.com/questions/32662123/pyodbc-error-data-source-name-not-found-and-no-default-driver-specified-paradox – jspcal Jul 20 '18 at 17:47
  • That's one of the ones I read through, that's how I learned exactly which driver I was using, thank you though. – E.Ostler Jul 20 '18 at 17:48
  • Try changing your driver like this: `"Driver={SQL Server};"` That has worked for me in the past. – sniperd Jul 20 '18 at 17:51
  • Don't put extraneous spaces in your connection string. For example, use `DRIVER={ODBC...` not `DRIVER = {ODBC...` – Gord Thompson Jul 20 '18 at 17:52
  • @GordThompson that fixed it, thank you very much! – E.Ostler Jul 20 '18 at 17:54
  • Possible duplicate of [PYODBC--Data source name not found and no default driver specified](https://stackoverflow.com/questions/46045834/pyodbc-data-source-name-not-found-and-no-default-driver-specified) – Gord Thompson Jul 20 '18 at 17:54
  • Probably this link will help you: https://stackoverflow.com/questions/46045834/pyodbc-data-source-name-not-found-and-no-default-driver-specified/57819021#57819021 – Avnish Tiwary Sep 06 '19 at 09:30

0 Answers0