Python 使用SQLAlchemy连接到数据库
我正在尝试连接到本地计算机上的数据库Python 使用SQLAlchemy连接到数据库,python,sqlalchemy,Python,Sqlalchemy,我正在尝试连接到本地计算机上的数据库 import sqlalchemy engine = sqlalchemy.create_engine('mssql+pyodbc://localhost\\SQLEXPRESS/NCM') 它失败,出现以下错误: DBAPIError: (pyodbc.Error) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default d
import sqlalchemy
engine = sqlalchemy.create_engine('mssql+pyodbc://localhost\\SQLEXPRESS/NCM')
它失败,出现以下错误:
DBAPIError: (pyodbc.Error) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
并输出此警告:
C:\Miniconda\envs\bees\lib\site-packages\sqlalchemy\connectors\pyodbc.py:82: SAWarning: No driver name specified; this is expected by PyODBC when using DSN-less connections
"No driver name specified; "
我应该在哪里诊断问题?如中所示,从1.0.0版开始,您需要为主机名连接明确指定驱动程序
Changed in version 1.0.0: Hostname-based PyODBC connections now require the
SQL Server driver name specified explicitly. SQLAlchemy cannot choose an
optimal default here as it varies based on platform and installed drivers.