Unsolved How to connect Qt with postgreSQL?
-
Thank you for replying, I am sorry, i am the beginner to Qt so will you please help me with the steps.
Thank you.
-
@mcosta , i tried running those commands in terminal but the response was..as follows
root@rcdtcpu24:/# cd $QTDIR/src/plugins/sqldrivers/psql
bash: cd: /src/plugins/sqldrivers/psql: No such file or directory
root@rcdtcpu24:/# qmake "INCLUDEPATH+=/usr/include/pgsql" "LIBS+=-L/usr/lib -lpq" psql.pro
Cannot find file: psql.pro.
root@rcdtcpu24:/# make
make: *** No targets specified and no makefile found. Stop.Please do help with the steps....
-
You should read the output more carefully:
bash: cd: /src/plugins/sqldrivers/psql: No such file or directoryThat means there is no /src/plugins/sqldrivers/psql directory.
QTDIR is not set. Just use the whole path to Qt sources directly. -
@vIJI
So you seem to be on Linux?If you have an installation of Postgres on your machine, then you have to find out
where Postgres include and lib directories are.The include these paths into your Qt project file (yourproject.pro).
-
Nope its not working......
i have added them, the location was just "/usr"....unix:INCLUDEPATH += /usr/include/
in .pro file but im unfortunate to get it success..can you tell me how to build it step by step please if you dont mind...
thank you.
-
@sirop The code posted uses Qt to connect to the DB; so he MUST use the plugin.
-
You are right about the code connecting to the DB.
But it is not true that you have to use QSql* in order to connect to the DB.
Postgres has C API for this purpose which one can easily write a C++ wrapper for.So my advice was: if Qt way is too abstract, do it with a C++ wrapper of Postgres C API.
-
@sirop, You're right: you don't have to use Qt to connect to the DB but the topic of the thread is How to connect Qt with PostgreSQL so probably the author wants to understand how to do it.
-
Hi,
@vIJI First thing to check: How did you install Qt ? Are you using the Online Installer ? Your distribution's package manager ?
If the former: did you install the Qt sources ? You can make that through the installer.
If the later, what distribution is it ? Most of them provide all database drivers. -
Hello,
First of all, you get this error because the postgresql you have installed is missing. You need to install the postgresql ODBC package. After installing it, you need to introduce the / bin file into the system environment or .pro
Good luck.