0

I am trying to connect to postgresql using pyside2. But, when I try to call the open method, the program stops running without showing any error.

This is my code:

from PySide2.QtSql import QSqlDatabase, QSqlQuery
from PySide2.QtWidgets import QApplication

app = QApplication([])

db = QSqlDatabase.addDatabase("QPSQL")
db.setHostName("localhost")
db.setDatabaseName("mydatabase")

ok = db.open("user", "password")

print("hola")

The line print("hola") show nothing.

I'm pretty sure there's an internal error happening, but I can't see it. If they need to see the error message, they will have to explain step by step how to get it.

I was searching on Google and it seems that I am the only one in the world that this happens to him. Thanks for any help you can give me.

Dante S.
  • 222
  • 3
  • 16

1 Answers1

0

I can not believe it. The problem was that it was not setting the port correctly. Now that I put the port right, it works perfect xD I don't know why it took me so long to notice.

 db.setPort(myport)
Dante S.
  • 222
  • 3
  • 16