我搜索了大约50篇有IM002错误的帖子,似乎无法弄清楚为什么得到它。完整的错误是:
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)')
我正在使用实例文件插入相关信息。
这是我所拥有的:
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;")