#include "database_handler.h" void DataBaseHandler::init() { auto databaseConf = DatabaseConfig::getIns(); qx::QxSqlDatabase::getSingleton()->setDriverName(databaseConf->getDriver()); qx::QxSqlDatabase::getSingleton()->setDatabaseName(databaseConf->getDatabase()); qx::QxSqlDatabase::getSingleton()->setHostName(databaseConf->getHost()); qx::QxSqlDatabase::getSingleton()->setPort(databaseConf->getPort()); qx::QxSqlDatabase::getSingleton()->setUserName(databaseConf->getUsername()); qx::QxSqlDatabase::getSingleton()->setPassword(databaseConf->getPassword()); qx::QxSqlDatabase::getSingleton()->setFormatSqlQueryBeforeLogging(true); QSqlDatabase database = qx::QxSqlDatabase::getSingleton()->getDatabase(); if(database.open()) { qWarning("database is connect success!"); } else { qWarning("database is connect failed!"); } }