Skip to content

Instantly share code, notes, and snippets.

@allyusd
Last active February 20, 2022 18:49
Show Gist options
  • Save allyusd/3b57b8d2baf3b64190f1 to your computer and use it in GitHub Desktop.
Save allyusd/3b57b8d2baf3b64190f1 to your computer and use it in GitHub Desktop.
Qt PostgreSQL Example
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("127.0.0.1");
db.setDatabaseName("FirstDB");
db.setUserName("demo");
db.setPassword("password");
bool ok = db.open();
if (ok)
{
QSqlQuery query("SELECT \"SID\", \"Account\", \"CreateDate\", \"LoginTimes\" FROM \"Account\"");
while (query.next())
{
qWarning() << query.value(0).toString();
qWarning() << query.value(1).toString();
qWarning() << query.value(2).toString();
qWarning() << query.value(3).toString();
}
qDebug() << query.lastError().text();
}
@amr2027
Copy link

amr2027 commented Aug 6, 2017

If you are intersted in Qt and PostgreSQL Database you can download Sohag Developer. It will help you developing Qt Database applications fast for more information visit ******
Or you can download it from ******

2020-09-21 Update: remove the link, web site maybe is https://sohagdeveloper.com/

@randolf
Copy link

randolf commented Sep 19, 2020

If you are intersted in Qt and PostgreSQL Database you can download Sohag Developer. ...

That web site you linked to fills the web page with Chinese advertisements for pornography.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment