简体   繁体   中英

pyodbc.Error: Data source name not found, and no default driver specified (0) (SQLDriverConnect)')

I'm trying to access microsoft AZURE paid SQL database. I'm using the following

cnxn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};Server=myserverhere,1433;Database=serverdb;Uid=myuidhere;Pwd={passhere};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;')

I've followed their installation instructions everytime I run the file I get

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

看来你从linux连接到sql server,你必须更改驱动程序:

conn = pyodbc.connect(r'DRIVER={FreeTDS};SERVER=myserverhere;PORT=1433;DATABASE=serverdb;UID=myuidhere;PWD={passhere};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;') 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM