You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
904 B
23 lines
904 B
1 year ago
|
|
||
|
#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!");
|
||
|
}
|
||
|
}
|