Skip to content

Instantly share code, notes, and snippets.

@shajeen
Created August 2, 2019 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shajeen/c0081321a362af7950488eb52114a84c to your computer and use it in GitHub Desktop.
Save shajeen/c0081321a362af7950488eb52114a84c to your computer and use it in GitHub Desktop.
access remote mysql db using qt framework
#include <QCoreApplication>
#include <QSqlDatabase>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL3");
db.setHostName("db4free.net");
db.setPort(3307);
db.setDatabaseName("testshajudb");
db.setUserName("");
db.setPassword("");
if (!db.open()) {
qDebug() << "unable to open database";
} else {
qDebug() << " db open success";
}
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment