Qt cannot connect Postgresql database different pc
-
I may not have been understood.
-
I create qt app on my computer and work on local. I use postgresql server and I can connect it. I take release on qtcreator. I add libs by windeployqt commond line.
-
I send release file to other computer.
-
I setup postgresql to other computer and it has same properties (databse name, username, user password, port)
But it could not connect. I wonder. do I need to make any additions when I get the release of the application? Or do you have any offer?
-
-
@Joe-von-Habsburg Then please add error handling to your application to get more information about the issue.
https://doc.qt.io/qt-6/qsqldatabase.html#lastErrorAlso, can you connect to the SQL server using the PostgreSQL client?
-
@Joe-von-Habsburg Also, check whether the sql plug-in was loaded: set QT_DEBUG_PLUGINS env variable before starting your app (see https://doc.qt.io/qt-6/debug.html).
-
@jsulm said in Qt cannot connect Postgresql database different pc:
Also, can you connect to the SQL server using the PostgreSQL client?
yes I can connect by pgadmin and I can do anything (insert, delete, select)
-
@Joe-von-Habsburg said in Qt cannot connect Postgresql database different pc:
yes I can connect by pgadmin and I can do anything (insert, delete, select)
So I said earlier:
and (c) you have the necessary permissions to access that database and its tables, e.g. your username is acceptable or whatever.
It does not sound like you are passing an acceptable user? If you say it works via pgadmin is that using username
postgres
as your code does?In any case please help yourself and us by following @jsulm's
Then please add error handling to your application to get more information about the issue.
You still have not told us which statement it fails on and what the error is (with
lastError()
for extended information). You should always put in such error handling, both to help you during development and for the end user to report if it goes wrong for whatever reason at runtime/after deployment. -
@Joe-von-Habsburg said in Qt cannot connect Postgresql database different pc:
how can I add it?
Did you also deploy the PostgreSQL client library together with your app?
Please post the output of the application after running it with QT_DEBUG_PLUGINS set, else we can only guess... -
@jsulm said in Qt cannot connect Postgresql database different pc:
Did you also deploy the PostgreSQL client library together with your app?
How can I do it? I do not know. I know problem is driver but how I am able to add it? if you could help me with this I would appreciate it. what dlls should I add or what should I add to cmake?
@jsulm said in Qt cannot connect Postgresql database different pc:
QT_DEBUG
I can not use Debug. I use release profile on qtcreator
-
@Joe-von-Habsburg
@jsulm did not ask you aboutQT_DEBUG
or Debug. He asked you to set environment variableQT_DEBUG_PLUGINS
(to value1
) before running your program. That will show diagnostic output which you will need to see what is happening/missing. You can look it up in the docs if you wish. -
-