Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: QT to Postgresql connection

  1. #21
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    9
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT to Postgresql connection

    ..........
    Last edited by KeithN; 10th November 2011 at 03:26.

  2. The following user says thank you to KeithN for this useful post:


  3. #22
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    9
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT to Postgresql connection

    Everything working now. Thanks again.

  4. The following user says thank you to KeithN for this useful post:


  5. #23
    Join Date
    Nov 2011
    Posts
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT to Postgresql connection

    Hi. I'm still fighting with this problem.

    I downloaded those drivers (from the link) and put those into "E:\QtSDK\Desktop\Qt\4.7.4\mingw\plugins\sqldriver s" -directory. After that I put "C:\psql\9.1\bin;" into system variable PATH. After that I restarted Nokia Qt Creator and pressed run my project and the result was still: QSqlDatabase:
    QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE

    This is though. I have fought and fought with this problem and it's still beating me. So please, I need help. Thank you.

  6. The following user says thank you to Jeewes87 for this useful post:


  7. #24
    Join Date
    Nov 2011
    Posts
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT to Postgresql connection

    Wohoo!! I solved the problem. I had 64bit version of the postgreSQL and 32bit-version was the one I should have used. Changeing the psql version solved the problem.

    So overall what I did to get the psql plugin work in my QtSDK:

    1. I downloaded psql drivers from the previously mentioned link. (You can also create those by your self incase url is not available).
    2. I added those driver files into "E:\QtSDK\Desktop\Qt\4.7.4\mingw\plugins\sqldr iver s" -directory.
    3. I added "C:\psql\bin;" (and just to make it sure also "C:\psql\lib;C:\psql\include;") to my PATH system variable.
    4. Finally started Qt creator and tested my code... ..and vóla!

    Thank's everyone.

  8. The following 2 users say thank you to Jeewes87 for this useful post:

    rivci (4th May 2012)

  9. #25
    Join Date
    May 2012
    Posts
    15
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT to Postgresql connection

    Good day everyone,

    I still encounter trouble with the QSPQL driver.
    Until the #13 post, everything worked fine.
    I followed these steps according to:
    http://www.qtcentre.org/wiki/index.p...s_using_MinGW;

    -Go to %QTDIR%/src/plugins/sqldrivers/psql. (for me: D:\Qt\2010.05\qt\src\plugins\sqldrivers\psql)
    -Run the following command: qmake -o Makefile "INCLUDEPATH+=C:\PostgreSQL\8.3\include" "LIBS+=C:\PostgreSQL\8.3\lib\libpq.a" psql.pro
    NB:I wrote: "qmake -o Makefile "INCLUDEPATH+=D:\PostgreSQL\include" "LIBS+=D:\PostgreSQL\lib\libpq.a" psql.pro" in order to match the correct destination.
    -Run make - this should build the qsqlpsql.dll and libqsqlpsql.a files in the %QTDIR%/plugins/sqldrivers directory. (where i ran :mingw32-make.)


    at this point i got in %QTDIR%/src/plugins/sqldrivers/psql
    Qt Code:
    1. 11/02/2012 15:46 <REP> .
    2. 11/02/2012 15:46 <REP> ..
    3. 26/05/2012 23:34 2*873 main.cpp
    4. 10/09/2010 10:05 514 psql.pro
    5. 10/09/2010 10:05 215 README
    6. 25/05/2012 19:09 781 qsqlpsqld_resource.rc
    7. 25/05/2012 19:09 <REP> tmp
    8. 25/05/2012 19:09 780 qsqlpsql_resource.rc
    9. 25/05/2012 19:09 24*845 Makefile.Debug
    10. 25/05/2012 19:09 24*693 Makefile.Release
    11. 25/05/2012 19:09 6*122 Makefile
    To copy to clipboard, switch view to plain text mode 
    I this point I noticed that I had no debug or release directory at all whereas it is the case in this discussion.

    Meanwhile:
    %QTDIR%/src/plugins/sqldrivers/psql>dir
    Qt Code:
    1. 11/02/2012 15:47 <REP> .
    2. 11/02/2012 15:47 <REP> ..
    3. 13/09/2010 06:16 2*168 libqsqlite4.a
    4. 13/09/2010 06:16 2*178 libqsqlited4.a
    5. 13/09/2010 06:17 2*178 libqsqlodbc4.a
    6. 13/09/2010 06:17 2*182 libqsqlodbcd4.a
    7. 13/09/2010 06:17 478*720 qsqlite4.dll
    8. 11/02/2012 15:56 1*736*365 qsqlited4.dll
    9. 13/09/2010 06:17 163*840 qsqlodbc4.dll
    10. 13/09/2010 06:17 971*676 qsqlodbcd4.dll
    11. 27/05/2012 12:16 889*883 qsqlpsqld4.dll
    12. 27/05/2012 12:16 2*182 libqsqlpsqld4.a
    13. 27/05/2012 12:16 123*392 qsqlpsql4.dll
    14. 27/05/2012 12:16 2*178 libqsqlpsql4.a
    To copy to clipboard, switch view to plain text mode 
    At this point, i have a test program:
    Qt Code:
    1. #include<QApplication>
    2. #include<QtSql/QSqlDatabase>
    3. #include<QDebug>
    4. #include<QtGui>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8.  
    9. QApplication a(argc, argv);
    10. QSqlDatabase bd = QSqlDatabase::addDatabase("QPSQL");
    11. qDebug() << QSqlDatabase::drivers();
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    and a .pro like this:
    QT+=sql

    SOURCES += \
    main.cpp

    Still nothing is working ouput:
    Qt Code:
    1. Démarrage de E:\cyril ***\Mes documents\Projets_Qt\test_connect_postgres1-build-desktop\debug\test_connect_postgres1.exe...
    2. QSqlDatabase: QPSQL driver not loaded
    3. QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
    4. ("QSQLITE", "QODBC3", "QODBC")
    5. E:\cyril ***\Mes documents\Projets_Qt\test_connect_postgres1-build-desktop\debug\test_connect_postgres1.exe s'est terminé avec le code 1
    To copy to clipboard, switch view to plain text mode 
    I'm not sure how to set correctly the right PAHT variable so i did like this inside the Qtenv.bat (or Qtvar.bat) name differs for a reason i ignore.
    Qt Code:
    1. @echo off
    2. rem
    3. rem This file is generated
    4. rem
    5. echo Setting up a MinGW/Qt only environment...
    6. echo -- QTDIR set to D:\Qt\2010.05\qt
    7. echo -- PATH set to D:\Qt\2010.05\qt\bin
    8. echo -- MINGW set to D:\Qt\2010.05\qt\mingw
    9. echo -- lib set to D:\Qt\2010.05\qt\lib;D:\Qt\2010.05\mingw\lib
    10. echo -- include set to D:\Qt\2010.05\qt\include;D:\Qt\2010.05\mingw\include
    11. echo -- Adding D:\Qt\2010.05\bin to PATH
    12. echo -- Adding %SystemRoot%\System32 to PATH
    13. echo -- QMAKESPEC set to win32-g++
    14. set QTDIR=D:\Qt\2010.05\qt
    15. set PATH=D:\Qt\2010.05\qt\bin
    16. set PATH=%PATH%;D:\Qt\2010.05\bin;D:\Qt\2010.05\mingw\bin
    17. set PATH=%PATH%;%SystemRoot%\System32
    18. set PATH=%PATH%;D:\PostgreSQL\bin;D:\PostgreSQL\lib;D:\PostgreSQL\include
    19. set QMAKESPEC=win32-g+
    To copy to clipboard, switch view to plain text mode 
    And i set the same in
    Users environnement PATH variable,
    System PATH environnemnet variable.

    I would be very glad to anyone of you, who will be able to help me as i have been working on that for 3 days now, searching on various topics.
    Best regards
    Thanks!

    Cyril.

    My configuration is: Windows XP SP3, PostgreSQL 9.1 and Qt4.7 QtSDK 2010.05
    Last edited by CyrilQt; 27th May 2012 at 15:19.

  10. The following user says thank you to CyrilQt for this useful post:


  11. #26
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QT to Postgresql connection

    See the wiki article directly related to the Qt SDK: [wiki]Building the Database Plugins for QtSDK Users[/wiki].

    The entire process on my machine:
    • Download and install PostgreSQL using the one click Windows installer. I installed under "D:\PostgreSQL" giving me "D:\PostgreSQL\9.1\bin" etc.
    • Change directory to the psql sql driver source directory and build:
      Qt Code:
      1. cd C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql
      2. qmake INCLUDEPATH+="d:/PostgreSQL/9.1/include" LIBS+="d:/PostgreSQL/9.1/lib/libpq.lib"
      3. mingw32-make
      4. mingw32-make install
      To copy to clipboard, switch view to plain text mode 
    • Compile and test your program in debug mode. The "D:\PostgreSQL\9.1\bin" directory needs to be in the user's PATH in order to use the plugin. The "...\lib" and "...\include" directories do not. I did that for testing purposes using the program run settings in Qt Creator.


    The default steps only installed the debug model plugin. You will also want the Release mode plugin:
    Qt Code:
    1. qmake INCLUDEPATH+="d:\PostgreSQL\9.1\include" LIBS+="d:\PostgreSQL\9.1\lib\libpq.lib" CONFIG+=release
    2. mingw32-make
    3. mingw32-make install
    To copy to clipboard, switch view to plain text mode 

  12. The following 2 users say thank you to ChrisW67 for this useful post:

    CyrilQt (28th May 2012)

  13. #27
    Join Date
    May 2012
    Posts
    15
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT to Postgresql connection

    Dear ChrisW67,

    I downloaded and install Qt SDK from:
    http://qt.nokia.com/downloads/sdk-windows-cpp-offline
    in the D:\QtSDK directory
    The path variable environnement checked with "Qt 4.8.1 Desktop (MinGW)" is set as followed
    Qt Code:
    1. PATH=D:\QtSDK\mingw\bin;D:\QtSDK\Desktop\Qt\4.8.1\mingw\bin;C:\WINDOWS\system32;C:\WINDOWS;
    2. C:\WINDOWS\System32\Wbem;C:\Program Files\Intel\Wireless\Bin\;
    3. D:\PostgreSQL\include;D:\PostgreSQL\lib;D:\PostgreSQL\bin;
    To copy to clipboard, switch view to plain text mode 
    As declare in Path i have the postgresql like this: D:\PostgreSQL

    so i ran:
    Qt Code:
    1. D:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql>qmake INCLUDEPATH +="D:/Pos
    2. tgreSQL/include" LIBS+="D:/PostgreSQL/lib/libpq.lib"
    To copy to clipboard, switch view to plain text mode 
    but showed:
    cannot find file INCLUDEPAHT
    so i shifted to
    Qt Code:
    1. D:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql>qmake "INCLUDEPATH +=D:/Pos
    2. tgreSQL/include" "LIBS+=D:/PostgreSQL/lib/libpq.lib"
    To copy to clipboard, switch view to plain text mode 
    then OK.
    then ran:
    mingw32-make
    console displays:
    Qt Code:
    1. Creating library file:debug\libqsqlpsqld4.a
    2. mingw32-make[1]: leaving directory'D:\QtSDK\QtSources\4.8.1\src\plugins
    3. \sqldrivers\psql'
    To copy to clipboard, switch view to plain text mode 
    that looks good.
    then i proceeded:
    Qt Code:
    1. D:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql>mingw32-make install
    2. mingw32-make -f Makefile.Debug install
    3. mingw32-make[1]: Entering directory `D:/QtSDK/QtSources/4.8.1/src/plugins/sqldri
    4. vers/psql'
    5. copy /y "debug\qsqlpsqld4.dll" "d:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\sqldrive
    6. rs\qsqlpsqld4.dll"
    7. 1 fichier(s) copié(s).
    8. mingw32-make[1]: Leaving directory `D:/QtSDK/QtSources/4.8.1/src/plugins/sqldriv
    9. ers/psql'
    10.  
    11. D:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql>
    To copy to clipboard, switch view to plain text mode 

    I opened my testing code:
    Qt Code:
    1. #include<QApplication>
    2. #include<QtSql/QSqlDatabase>
    3. #include<QDebug>
    4. #include<QtGui>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8.  
    9. QApplication a(argc, argv);
    10. QSqlDatabase bd = QSqlDatabase::addDatabase("QPSQL");
    11. qDebug() << QSqlDatabase::drivers();
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 
    and it answered me:
    Qt Code:
    1. Démarrage de E:\cyril\Mes documents\Projets_Qt\test_connect_postgres1-build-desktop\debug\test_connect_postgres1.exe...("QSQLITE", "QODBC3", "QODBC", "QPSQL7", "QPSQL")
    To copy to clipboard, switch view to plain text mode 
    THANK YOU SO MUCH for helping me!!!

    Best regards,
    eternal gratitude.

    Cyril.

  14. The following user says thank you to CyrilQt for this useful post:


  15. #28
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QT to Postgresql connection

    The error message regarding INCLUDEPATH is because you inckluded a space between the INCLUDEPATH and the "+=..." so Windows was treating it as two arguments, which in turn lead qmake to look for a file called INCLUDEPATH.
    Qt Code:
    1. D:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql>qmake INCLUDEPATH +=D:/PostgreSQL/include LIBS+=D:/PostgreSQL/lib/libpq.lib
    2. // ^^^ Here
    To copy to clipboard, switch view to plain text mode 
    Your quotes forced Windows to treat it as one argument and pass it to qmake as one argument. You could have left the space out, as in my example and the wiki page, with the same effect.

  16. The following 2 users say thank you to ChrisW67 for this useful post:

    CyrilQt (17th June 2012)

  17. #29
    Join Date
    Nov 2013
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QT to Postgresql connection

    Quote Originally Posted by ChrisW67 View Post
    See the wiki article directly related to the Qt SDK: [wiki]Building the Database Plugins for QtSDK Users[/wiki].

    The entire process on my machine:
    • Download and install PostgreSQL using the one click Windows installer. I installed under "D:\PostgreSQL" giving me "D:\PostgreSQL\9.1\bin" etc.
    • Change directory to the psql sql driver source directory and build:
      Qt Code:
      1. cd C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql
      2. qmake INCLUDEPATH+="d:/PostgreSQL/9.1/include" LIBS+="d:/PostgreSQL/9.1/lib/libpq.lib"
      3. mingw32-make
      4. mingw32-make install
      To copy to clipboard, switch view to plain text mode 
    • Compile and test your program in debug mode. The "D:\PostgreSQL\9.1\bin" directory needs to be in the user's PATH in order to use the plugin. The "...\lib" and "...\include" directories do not. I did that for testing purposes using the program run settings in Qt Creator.


    The default steps only installed the debug model plugin. You will also want the Release mode plugin:
    Qt Code:
    1. qmake INCLUDEPATH+="d:\PostgreSQL\9.1\include" LIBS+="d:\PostgreSQL\9.1\lib\libpq.lib" CONFIG+=release
    2. mingw32-make
    3. mingw32-make install
    To copy to clipboard, switch view to plain text mode 
    Hello ChrisW67,

    I am having troubles with Qt 5.1.1 when I try to build the plugin.

    What I did:
    - Added the directory C:\Program Files\PostgreSQL\9.3\bin with the C:\>set path=%path%;C:\Program Files\PostgreSQL\9.3\bin command.
    - Tried C:\Qt\5.1.1\Src\qtbase\src\plugins\sqldrivers\psql >qmake INCLUDEPATH+="C:/Program Files/PostgreSQL/9.3/include" LIBS+="C:/Program Files/PostgreSQL/9.3/lib/libpq.lib" but I got the error below:
    'qmake' is not recognized as an internal or external command, operable program or batch file.
    - Searched where qmake is located and tried to execute the command above from there:

    C:\Qt\5.1.1\mingw48_32\bin>qmake -makefile INCLUDEPATH+="C:/Program Files/PostgreSQL/9.3/include" LIBS+="C:/Program Files/PostgreSQL/9.3/lib/libpq.lib"

    but instead I got answer how to use qmake:

    Usage: qmake [mode] [options] [files]

    QMake has two modes, one mode for generating project files based on
    some heuristics, and the other for generating makefiles. Normally you
    shouldn't need to specify a mode, as makefile generation is the default
    mode for qmake, but you may use this to test qmake on an existing project

    Mode:
    -project Put qmake into project file generation mode
    In this mode qmake interprets files as files to
    be built,
    defaults to *; *; *; *.ts; *.xlf; *.qrc
    Note: The created .pro file probably will
    need to be edited. For example add the QT variable to
    specify what modules are required.
    -makefile Put qmake into makefile generation mode (default)
    In this mode qmake interprets files as project files to
    be processed, if skipped qmake will try to find a project
    file in your current working directory
    <output omitted>

    -Also tried to include the -makefile but the result is again how to use.

    Could you please review this and advise?

    Thanks in advance for your cooperation.

    Best regards,
    TerraxQt

  18. The following user says thank you to TerraxQt for this useful post:


Similar Threads

  1. Replies: 2
    Last Post: 11th February 2011, 17:53
  2. Replies: 1
    Last Post: 2nd April 2010, 06:42
  3. requiredStatus on Qt 4.3 and PostgreSQL 8.3.3
    By Auryn in forum Qt Programming
    Replies: 9
    Last Post: 2nd September 2008, 22:06
  4. postgreSQL - Last Inserted ID
    By nnidza in forum Qt Programming
    Replies: 4
    Last Post: 2nd April 2007, 08:09
  5. QT4 and Postgresql driver
    By alphaqt in forum Installation and Deployment
    Replies: 6
    Last Post: 27th February 2006, 15:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.