Solved QPSQL: Unable to create query
-
@Christian-Ehrlicher I tried making a query in psql and the query works.
I also tried to make this requestQSqlQuery query("select * from public.account"); QSqlError error = query.lastError(); if (error.type() == QSqlError::NoError) { while(query.next()) { qDebug() << query.value(0).toString(); } } else { qDebug() << error.text(); }
But I got the error of not having a table, whereas the table is exactly there.
-
The table is 'account', the schema public - try without schema
-
@Christian-Ehrlicher Can there be a problem with a bad driver?
-
@Christian-Ehrlicher it is too not work:
QSqlQuery query("SELECT * FROM account ", dataBase); if (!query.exec()) { qDebug()<<"not get data from db \r\n"<<query.lastError()<<"\r\n"; qDebug()<<query.lastQuery(); } else { qDebug()<<"get data from db \r\n"; query.first(); } return resultVector;
-
I use psql 12 in the windows 7 64
-
So where do you get the error? during query.exec()? And what error? The same as in the first post?
-
@Christian-Ehrlicher said in QPSQL: Unable to create query:
query.exec()
Yes, in query.exec(). The same error. Looks like it's the driver. How do I find out which version of the driver is designed for?
-
Do you connect PSQL to the project and it works normally?
-
@Mikeeeeee I'm using psql since ages with Qt. Imo it's a problem with your psql installation. Simply test it with a sqlite database. Also you should take a look what others did to solve the psql 42601 error but that's not Qt related
-
Before the update, I had PSQL working, after the update, new drivers were added and it stopped working.
-
Thenswitch back to the old PostgreSQL - or do you really need some new features in PostgreSQL 12 (btw: psql 12 is supported since Qt5.14 and works fine here)
-
Sorry, I'm in a connection indicated is not the base, my stupid mistake.