PyOdbc fails to connect to a sql server instance

前端 未结 2 772
Happy的楠姐
Happy的楠姐 2021-01-19 20:37

I am trying to connect to a sql server instance using pyodbc version 3.0.6., SQLAlchemy 1.0.4 on Windows 7 using a Python 2.7 (32 bit). I am using a connection string as fol

2条回答
  •  伪装坚强ぢ
    2021-01-19 21:36

    OK, this seems to have resolved the issue

    import urllib    
    connection_string = "DRIVER={SQL Server};Database=people;SERVER=gagan;UID=sa;PWD=admin1"
    connection_string = urllib.quote_plus(connection_string) 
    connection_string = "mssql+pyodbc:///?odbc_connect=%s" % connection_string
    

提交回复
热议问题