【问题标题】:Connect to mssql from sqlalchemy by pyodbc on mac os在 mac os 上通过 pyodbc 从 sqlalchemy 连接到 mssql
【发布时间】:2011-06-07 14:18:26
【问题描述】:

有人在 sqlalchemy 中通过 pyodbc 成功连接到 mssql 吗?我现在正在使用turbogears2,并尝试连接到mssql,在mac os平台上工作。

出现以下错误:

sqlalchemy.exc.DBAPIError: (Error) ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (0) (SQLDriverConnectW)') None None

【问题讨论】:

  • 您要运行的代码在哪里?
  • 另外,您是否为 mssql 安装了任何 odbc 驱动程序?
  • 非常感谢您的回复。以下是我在 python shell 中直接使用的一些示例代码: >>> import sqlalchemy >>> engine=sqlalchemy.create_engine('mssql+pyodbc://sa:password@host/hf_export') >>> con=engine.connect ()
  • 我认为你是对的,也许我缺少 ODBC 驱动程序,我安装了 pyodbc,显然它不是驱动程序。
  • 你找到OSX的驱动了吗?

标签: python macos sqlalchemy pyodbc turbogears2


【解决方案1】:

有比旧的 macports 或 fink 更好的方法,brew

brew install freetds unixodbc

而且它甚至不需要root来安装它。

【讨论】:

    【解决方案2】:

    MacPort 的简单方法

    只需通过以下方式进行安装:

        sudo port install freetds +mssql +odbc +universal
    

    这将安装 freetds 和 unixODBC,我们可以使用 unixODBC 进行 ODBC 管理,或者使用 Mac OS 附带的 iODBC。

    编译安装

        ./configure --prefix=/usr/local/lib/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static
        make
        make install
    

    TDSVER 设置

    要连接到 SQL Server 2005/8,请确保将 tds 版本设置为 8.0,使用以下终端命令:

        export TDSVER = 8.0
    

    语言设置

    确保已设置正确的语言:

        export LC_ALL=en_US.UTF-8
    

    【讨论】:

    • ./configure 命令应该在哪个目录下?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 2019-02-26
    • 1970-01-01
    • 2021-07-12
    • 2016-05-21
    • 2019-08-06
    相关资源
    最近更新 更多