Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED]Postgres Driver on Ubuntu



  • hi all

    I already readed docs on the forum. But nothing works until now.
    @ QSqlDatabase *db = new QSqlDatabase();
    db->addDatabase("QPSQL");
    qDebug()<<db->driverName();
    qDebug()<<db->drivers();
    db->setHostName("localhost");
    db->setDatabaseName("mydb");
    db->setUserName("brochadinho");
    db->setPassword("12345");
    qDebug() << qApp->libraryPaths();
    bool ok = db->open("brochadinho","12345");
    if(ok==true){
    qDebug()<<"sucesso a ligar a base de dados de teste";
    }else{
    qWarning()<<"Erro"<<db->lastError().text();
    }@
    output
    @("QSQLITE", "QMYSQL", "QMYSQL3", "QPSQL", "QPSQL7")
    ("/home/brochadinho/Qt/5.3/gcc_64/plugins", "/home/brochadinho/build-projectoEFactura-Desktop_Qt_5_3_GCC_64bit-Debug")
    Erro: "Driver not loaded Driver not loaded"@

    and then i tried to compile the driver and...

    @brochadinho@luispc:~/Qt/5.3/Src/qtbase/src/plugins/sqldrivers/psql$ qmake "INCLUDEPATH+=/usr/include/postgresql" "LIBS+=-L/usr/lib -lpq" psql.pro
    WARNING: /home/brochadinho/Qt/5.3/Src/qtbase/src/plugins/sqldrivers/qsqldriverbase.pri:4: Unable to find file for inclusion qt_plugin
    Project MESSAGE: Warning: unknown QT: core-private
    Project MESSAGE: Warning: unknown QT: sql-private
    @

    i have Qt Creator 3.2.2 (opensource) Based on Qt 5.3.2 (GCC 4.6.1, 64 bit) on a ubuntu 14.04 LTS 64bit. the postgres was installed via apt-get postegres.

    Any sugestion how to put this working? at have been struglling with this, for 2 days.

    thanks for all the help.


  • Lifetime Qt Champion

    Hi,

    Are you sure that the qmake you are calling is the one from Qt 5.3 ? Also, from what I read, you already have the plugin built. You should run ldd on the original plugin to see if you have a missing dependency.

    Hope it helps



  • Hi thanks for the reply.

    U are right about the qmake thing.But something real weird is happening. I Compile the drilldown example, and i made some changes and it worked.

    @ QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    qDebug()<<db.drivers();
    db.setDatabaseName("mydb");
    db.setUserName("postgres");
    db.setPassword("postgres");
    db.setHostName("localhost");
    db.setPort(5432);@
    I allready, tried this snippet on my project, and it worked.

    Looks like the problem was the db.port wasn't define. But im not sure. as long as it works, i don't care.


  • Lifetime Qt Champion

    Some database system needs more information than others so it might very well be that.


Log in to reply