J
J
jonikwm2015-09-24 21:38:17
MySQL
jonikwm, 2015-09-24 21:38:17

Why does QSqlDatabase.open() always return True?

I read from the documentation that QSqlDatabase.open() Opens a database connection and returns True on success and False on failure.
But in practice, "at least piss in the eyes - all God's dew."
Regardless of the connection result, I get True.

from PyQt5.QtSql import 
db = QSqlDatabase.addDatabase("QMYSQL")
db.setHostName("acidalia")
db.setDatabaseName("customdb")
db.setUserName("mojito")
db.setPassword("J0a1m8")
ok = db.open()
print(db.open()) #почему всегда True???
db.close()

Help solve the problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-09-25
@sim3x

db.open()tells you that he connected to the database and now you can work through db

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question