PyQT 找不到任何 SQL 驱动程序 [英] PyQT can't find any SQL drivers

查看:40
本文介绍了PyQT 找不到任何 SQL 驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 PyQT 应用程序并想使用 SQL 数据库.发动机没那么重要.我的系统中安装了一个可以运行的 MySQL(我经常使用它),并且默认情况下在我的 system32 文件夹中存在 SQLite3 DLL,并且我还在 qsqlite dll 旁边放了一个副本.

但是当我打电话

db = QtSql.QSqlDatabase.addDatabase("QSQLITE")

db = QtSql.QSqlDatabase.addDatabase("QMYSQL")

我得到的是:

QSqlDatabase:未加载 QSQLITE 驱动程序QSqlDatabase:可用的驱动程序:

根本没有驱动程序.我应该怎么办?提前致谢.

解决方案

我的英语不太好.

我在 windows 10 下使用 Python 2.7,Postgresql,并在 QT 中开发 gui,使用 PyQt4 和 QtSql.并使用spyder.(实际上一切都包含在 Python ( x , y) 中)

,-) 但这是一个简单的解决方案.打开文件 C:\Python27\qt.conf,首先我在文件里面有这几行:

Prefix = C:/Python27/Lib/site-packages/PyQt4二进制文件 = C:/Python27/Lib/site-packages/PyQt4

然后添加下一行:

Plugins = C:/Python27/Lib/site-packages/PyQt4/plugins翻译 = C:/Python27/Lib/site-packages/PyQt4/translations

确保插件在 C:/Python27/Lib/site-packages/PyQt4/plugins 中.然后关闭python并再次打开.然后所有的工作完美.您在这里找到了相同的答案 http://www.voidynullness.net/blog/2013/01/24/pyqt-database-driver-loading-issues-on-windows-after-installing-pyside/>

I'm developing a PyQT application and want to use a SQL database. The engine doesn't matter that much. And I have a working MySQL installed in my system (I use it frequently), and also the SQLite3 DLL is present, by default in my system32 folder, and I have also put a copy beside qsqlite dll.

But when I call

db = QtSql.QSqlDatabase.addDatabase("QSQLITE")

or

db = QtSql.QSqlDatabase.addDatabase("QMYSQL")

All I get is:

QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers:

No Drivers at all. What should I do? Thanks in advance.

解决方案

I don't speak english very well.

I use Python 2.7 under windows 10, Postgresql, and developt the gui in QT , use PyQt4 and QtSql. And use spyder. (In reality everything is included in Python ( x , y))

,-) but here is the easy solution. Open the file C:\Python27\qt.conf, First I had inside the file this lines:

Prefix = C:/Python27/Lib/site-packages/PyQt4
Binaries = C:/Python27/Lib/site-packages/PyQt4

then you add the next lines:

Plugins = C:/Python27/Lib/site-packages/PyQt4/plugins
Translations = C:/Python27/Lib/site-packages/PyQt4/translations

Make sure that the plugins are in C:/Python27/Lib/site-packages/PyQt4/plugins. Then close python and open again. Then all work perfectly. You found the same answer here http://www.voidynullness.net/blog/2013/01/24/pyqt-database-driver-loading-issues-on-windows-after-installing-pyside/

这篇关于PyQT 找不到任何 SQL 驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆