I folks!
I'm new in the Qt and PyQt world, more precisely in the latter! At the moment I'm using PyQt 5.6 with Python 3.5 and i'mtrying to connect my simple app to a local MySQL server. I managed to open the server, but unfortunately the program crash whenever I commit a query (Which i'm sure it's correct since it works fine on SQLyog).
My code is the following:
from PyQt5 import QtWidgets, QtSql
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QApplication
import sys
app = QApplication(sys.argv)
db = QtSql.QSqlDatabase.addDatabase("QMYSQL")
db.setHostName("localhost")
db.setUserName("root")
db.setPort(3306)
db.setDatabaseName("users")
db.setPassword("")
db.open()
if db.open():
print("Db open!")
query = QtSql.QSqlQuery(db)
query.exec_("SELECT * FROM userscredentials")
print(query.value(0))
else:
print("Db not open")
input("")
sys.exit(app.exec_())
and i got the following output
C:\Python35\python.exe C:/Users/Egon/PycharmProjects/PyQt/DemoSQL/mainFIle.py
Db open!
Process finished with exit code -1073741819 (0xC0000005)
Can you please help me to understand the problem ?
Bookmarks