Created
August 2, 2019 17:43
-
-
Save shajeen/c0081321a362af7950488eb52114a84c to your computer and use it in GitHub Desktop.
access remote mysql db using qt framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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