Skip to content
  • 0 Votes
    14 Posts
    788 Views
    J

    @JonB I do not understand anything. Please could you give more informantion.

    Note : app release folder has
    a476d8a3-0275-4b95-be08-69e8e7ca83ca-image.png

    I solved the problem :)

    I add lib files from Postgresql to release folder
    341075a5-d9d5-4598-9bb3-6bbae3cee52c-image.png

    and it works. thank you @jsulm and @JonB

  • 0 Votes
    7 Posts
    1k Views
    T

    @Christian-Ehrlicher Yup.. it worked when i upgraded my Qt version. Thanks a lot.

    Just for education purposes, can i ask lets say if i am still using qt 5.8.0 and i wish to remove this message. Is there a way to do that? I believe this message is caused by this qt sqldriver file called qsql_psql.cpp. So I tried to remove the code that prompts this message in qsql_psql.cpp file and it didnt work when i run my application.

  • 0 Votes
    7 Posts
    2k Views
    JonBJ

    @thaidy said in QT Deploy QPSQL Plugin:

    @hskoglund said in QT Deploy QPSQL Plugin:

    what happens if you move the declaration into for example your MainWindow.h class:
    QSqlDatabase DB;
    DB = QSqlDatabase::addDatabase("QPSQL"):

    IT WAS THAT, THANK YOU VERY MUCH!!

    Glad this has solved problem, certainly better than some static variable.

    However, this is still not right/advised. Per https://doc.qt.io/qt-5/qsqldatabase.html#details, red box warning:

    Warning: It is highly recommended that you do not keep a copy of the QSqlDatabase around as a member of a class, as this will prevent the instance from being correctly cleaned up on shutdown. If you need to access an existing QSqlDatabase, it should be accessed with database(). If you chose to have a QSqlDatabase member variable, this needs to be deleted before the QCoreApplication instance is deleted, otherwise it may lead to undefined behavior.

    Qt asks you to simply call
    static QSqlDatabase QSqlDatabase::database(const QString &connectionName = QLatin1String(defaultConnection), bool open = true)
    whenever you need to access a QSqlDatabase, and not to keep even a member variable QSqlDatabase around. You don't need it.

  • 0 Votes
    2 Posts
    298 Views
    D

    Well, I have discovered my problem.
    I was trying to read the file before closing it:

    QString cadenaimportar = "SELECT importar_copy('" + tabla + "','/path/conceptos.csv',)"; ...... file.close();

    And it would be:

    file.close(); QString cadenaimportar = "SELECT importar_copy('" + tabla + "','/path/conceptos.csv',)"; QSqlQuery consulta(db); if(consulta.prepare(cadenaimportar)) { consulta.exec(); } qDebug()<<consulta.lastError()<<"--"<<consulta.lastQuery();
  • 0 Votes
    6 Posts
    1k Views
    JonBJ

    @OpenGL
    I'm not defending this other than as a nasty hack. But if what you say is true, and you are stuck looking for a workaround: you can pass input parameters by interpolating them literally into the call() statement, and you can receive output parameters by returning them via a SELECT statement at the end of a call()ed procedure. Assuming you get a result set back from the call() which the driver can retrieve.

  • 0 Votes
    41 Posts
    6k Views
    R

    Upgrading to Qt Version 5.15+ solved the issue.

  • 0 Votes
    13 Posts
    3k Views
    Christian EhrlicherC

    @bartoszpaj said in BindValue() in QPSQL is not working?:

    driver()->hasFeature(QSqlDriver::NamedPlaceholders) returns false.

    Good catch. I think it's because support for PostgreSQL 10 was added in a later version. If the version is not known to the driver it will fall back to the oldest.

  • 0 Votes
    7 Posts
    2k Views
    R

    Thanks,

    I tried it without success.

    For me it seems the documentation is not up to date as the named folder sturcture is not existing in the EnterpriseDB installer installed version or in the official sources.

    I also looked whether there is something like an extra psql module to download, but have not found anything.

  • 0 Votes
    8 Posts
    2k Views
    ivandI

    Hi,
    Did you succeed to compile the PostgreSQL plugin for android?

  • 1 Votes
    16 Posts
    5k Views
    L

    To use it as a model for QTableView with PostgreSQL 9.1 on PySide2, I subclass QSqlTableModel and rewrite the function insertRowIntoTable (assuming the primary key of serial type is the first field of the record) :

    def insertRowIntoTable(self, values): if QSqlTableModel.insertRowIntoTable(self, values): # returns the value of the primary key "autovalue" (serial) only when the record is added in database rs = QSqlQuery() rs.exec_("SELECT CURRVAL (pg_get_serial_sequence('public." + self.tableName() + "','"+ self.primaryKey().field(0).name() +"'))") if rs.next(): ID = rs.value(0) # without this line the row displayed in the QTableView immediately after insertion cannot be updated self.setData (self.index(self.rowCount()-1,0), ID) # without this line the created row appears blank in the QTableView values.remove(0) return True return False
  • 0 Votes
    5 Posts
    4k Views
    jsulmJ

    @dawidp said in Sqldrivers: Postgresql not found while it is installed and configured (win 8.1, Psql 9.6.6, Qt 5.10.0, MSVC2015_x64):

    And Qt installer was download from Qt website

    The Qt installer can install any officially provided Qt version, so you should know what Qt version you actually installed.

  • 0 Votes
    1 Posts
    914 Views
    No one has replied
  • 0 Votes
    4 Posts
    2k Views
    SGaistS

    Did you build the PostgreSQL plugin as part of your build ?
    If not then follow the documentation about QtSQL plugin build.

    Otherwise, rebuild Qt and include the driver directly but you'll have to do it from a clean build.

  • 0 Votes
    18 Posts
    13k Views
    M

    Thank you very much @SGaist and @raven-worx for helping me out. I fixed this issue by using runtime libraries from this project:
    https://sourceforge.net/projects/postgresql-mingw-w64/

  • 0 Votes
    2 Posts
    1k Views
    P

    Hello,
    I don't think it's that simple as you try to make it, at least if you want to include the data too.
    Few years ago I had a similar problem and I wrote a function for that purpose. I'm copying-pasting the code from my old post after some reformatting to be readable. Although I have improved the code a bit since then in my own app, this should help you get started (please check the indentation, some fixes may be needed). This function doesn't transfer the schema, but I think it's easy to include it.

    void DbManager::exportTables() { QHash<QString,QStringList> tablesWithFields; //It holds the table name and its fields QStringList tables = sourceDb.tables(); QSqlQuery query(sourceDb); foreach(const QString &table,tables) { query.exec(QString("PRAGMA TABLE_INFO(%1)").arg(table)); QStringList fields; while(query.next()) { fields << query.value(1).toString(); } tablesWithFields.insert(table,fields); } QFile f(QDir::homePath() + "/myDump.sql"); f.open(QIODevice::Append | QIODevice::Text); QTextStream streamer(&f); //If constraints can't be dropped in the target database, some reordering of //the INSERT statements may be needed QStringList sortedTables = tablesWithFields.keys(); sortedTables.move(sorted.indexOf("table1"),0); ... streamer << "BEGIN;\n"; foreach(const QString &table,sortedTables) { if(table=="sqlite_sequence" /*|| table=="table4", etc*/) continue; QString statement = QString("INSERT INTO %1 VALUES('").arg(table); QStringList fields = tablesWithFields.value(table); QString fieldsString = fields.join(","); query.exec(QString("SELECT %1 FROM %2").arg(fieldsString).arg(table)); if(!query.next()) continue; query.previous(); while(query.next()) { for(int i=0; i < fields.size(); ++i) { QString value = query.value(i).toString(); value.replace("'","''"); //Handle single quotes inside strings if(value.isEmpty()) { value = "NULL"; statement.chop(1); //NULL should not appear inside quotes statement.append(value+",'"); } else { statement.append(value+"','"); } } statement.chop(2); //Remove comma and single quote from the end of value group statement.append("),('"); //Close the value group and start a new one } statement.chop(3);//Remove comma, opening parenthesis, single quote from the end streamer << statement << ";\n"; //Complete the INSERT statement } streamer << "COMMIT;"; f.close(); }

    And then batch execute the sql file like this:

    ... exportTables(); QSqlQuery query(targetDb); QFile f(QDir::homePath()+"/myDump.sql"); f.open(QIODevice::ReadOnly | QIODevice::Text); if(!query.exec(f.readAll())) qCritical() << "Can't execute sql file: " << query.lastError().text();
  • 0 Votes
    2 Posts
    1k Views
    ?

    @Chris-B Hi, and welcome to the Qt forum! Please post the exact text of the warning and please show us the code that triggers the warning.

  • Tipo para imagem

    Unsolved Portuguese
    3
    0 Votes
    3 Posts
    2k Views
    L

    Eu acho que não foi bem isso o que ele perguntou. A resposta seria QByteArray ou QImage.

  • 0 Votes
    7 Posts
    3k Views
    T

    Hi,

    I build PostgreSQL plugin for IOS (iphonesimulator)
    When compiling errors appear:
    clang: error: invalid architecture ‘arm’ for deployment target ‘mios-simulator-version-min=5.1.1’
    clang: error: invalid architecture ‘aarch64’ for deployment target ‘mios-simulator-version-min=5.1.1’

    How do I solve it? Thank you!