我正在使用连接字符串从 sqlalchemy 成功连接到我的 sqlexpress 实例:
connection_str = 'mssql+pyodbc://mylaptop\sqlexpress/master?driver=SQL+Server+Native+Client+11.0&trusted_connection=yes'
我将如何连接到非默认端口上的 sql 实例,这可能吗?
connection_str = 'mssql+pyodbc://mylaptop\sqlexpress:1433/master?driver=SQL+Server+Native+Client+11.0&trusted_connection=yes'
是我期望的连接字符串,但这会返回错误:
(pyodbc.OperationalError) ('08001', '[08001] [Microsoft][SQL Server Native Client 11.0]TCP Provider: No connection could be made because the target machine actively refused it.\r\n (10061) (SQLDriverConnect); [08001] [Microsoft][SQL Server Native Client 11.0]Login timeout expired (0); [08001] [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. (10061)
我已经尝试了许多与端口的组合,但没有看到合法的组合?