PyOdbc fails to connect to a sql server instance

前端 未结 2 770
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条回答
  •  -上瘾入骨i
    2021-01-19 21:38

    There are other drivers available in Windows ecosystem, you can try the other 2 as well :)

    There are actually two or three SQL Server drivers written and distrubuted by Microsoft: one referred to as "SQL Server" and the other as "SQL Native Client" and "SQL Server Native Client 10.0}".

    DRIVER={SQL Server};SERVER=cloak;DATABASE=test;UID=user;PWD=password

    DRIVER={SQL Native Client};SERVER=dagger;DATABASE=test;UID=user;PWD=password

    DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATABASE=test;UID=user;PWD=password

    Reference: https://code.google.com/p/pyodbc/wiki/ConnectionStrings

    EDIT: 1

    Since SQLSoup which is written on top of SQLAlchemy you will have to use the following connection string:

    "mssql+pyodbc://sa:admin1@mymachinename/mydb"
    

    Reference: http://docs.sqlalchemy.org/en/rel_0_8/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc

提交回复
热议问题