使用PyQt连接到SQL Server

时间:2019-01-09 23:54:46

标签: qt pyqt pyqt5

如何使用Qt连接到SQL Server(在Mac上开发)

我一直在尝试首先遵循本指南来安装ODBC驱动程序,但是它http://doc.qt.io/qt-5/sql-driver.html#qodbc

不能正常工作

在第2步中,说要运行

qmake -- ODBC_PREFIX=/usr/local/unixODBC

我实际上已经更改了该路径,以指向unixODBXC的全新下载

qmake -- ODBC_PREFIX=/Users/userx/Downloads/unixODBC-2.3.7

最终的输出是

Running configuration tests...
Done running configuration tests.

Configure summary:

Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... no

Qt is now configured for building. Just run 'make'.
Once everything is built, Qt is installed.
You should NOT run 'make install'.
Note that this build cannot be deployed to other machines or devices.

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

然后,当我运行make sub-odbc时,我会得到

> make sub-odbc
make: *** No rule to make target `sub-odbc'.  Stop.
export PATH=$PATH:/Users/userx/Qt/5.12.0/clang_64/bin
cd /Users/userx/Qt/5.12.0/Src/qtbase/src/plugins/sqldrivers
qmake -- ODBC_PREFIX=/Users/userx/Downloads/unixODBC-2.3.7
make sub-odbc

我完全按照指示进行操作,但是似乎没有任何指示或建议吗?

1 个答案:

答案 0 :(得分:0)

我知道已经很晚了,但是尝试

export PATH=$PATH:/Users/userx/Qt/5.12.0/clang_64/bin
cd /Users/userx/Qt/5.12.0/Src/qtbase/src/plugins/sqldrivers

echo "" > config.cache
echo "" > config.log

qmake -- ODBC_PREFIX=/Users/userx/Downloads/unixODBC-2.3.7
make sub-odbc