【问题标题】:pyodbc cant connect mssql (Timeout)pyodbc 无法连接 mssql(超时)
【发布时间】:2017-12-22 00:56:11
【问题描述】:

我的 Windows 主机中有 mssql,VMware 中有 ubuntu。我尝试将虚拟机中的这个 mssql 与 python 中的 pyodbc 模块连接起来。

import pyodbc

server = '192.168.0.19'//host ip
database = 'mytestdb'
username = 'sa'
port = "1433"
password = 'mypassword'
cnxn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';PORT='+port+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()

与我的 mssql 实例的远程连接已启用,我可以使用相同的凭据登录,所以这里可能有什么问题?

【问题讨论】:

    标签: python pyodbc


    【解决方案1】:

    在一个变量中尝试SERVERPORT,如下所示: server = '192.168.0.19, 1433' 并删除 PORT

    如果这不起作用,请在DRIVER 中尝试{SQL Server}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-21
      • 1970-01-01
      • 1970-01-01
      • 2017-06-24
      • 2014-12-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多