Using pyodbc cause error: Data source name not found and no default driver specified

与世无争的帅哥 提交于 2019-11-29 12:20:00

As noted in the relevant section of the SQLAlchemy documentation:

Hostname-based connections are not preferred, however are supported. The ODBC driver name must be explicitly specified

So, you need to add the driver name to your connection string:

engine = create_engine('mssql+pyodbc://sa:123@localhost/TrainQuizDB?driver=ODBC+Driver+17+for+SQL+Server')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!