mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
完成系统管理web端功能,实现系统管理服务端接口,实现登录功能
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
//#include "Spdlogger.h"
|
||||
#include "Logger.h"
|
||||
|
||||
MysqlClient::MysqlClient(MysqlOptions opts) : options_(opts)
|
||||
MysqlClient::MysqlClient(MysqlOption option) : option_(option)
|
||||
{
|
||||
conn();
|
||||
}
|
||||
@@ -20,9 +20,10 @@ int MysqlClient::conn()
|
||||
return 0;
|
||||
}
|
||||
mysql_ = mysql_init(nullptr);
|
||||
MYSQL* ret = mysql_real_connect(mysql_, options_.host.c_str(), options_.user.c_str(), options_.password.c_str(), options_.dbname.c_str(), options_.port, NULL, 0);
|
||||
MYSQL* ret = mysql_real_connect(mysql_, option_.host.c_str(), option_.user.c_str(), option_.password.c_str(), option_.dbname.c_str(), option_.port, NULL, 0);
|
||||
if (ret == NULL)
|
||||
{
|
||||
std::string err = mysql_error(mysql_);
|
||||
//Spdlogger::info("[mysql] connect failed: {}", mysql_error(mysql_));
|
||||
mysql_ = nullptr;
|
||||
}
|
||||
@@ -49,7 +50,7 @@ void MysqlClient::close()
|
||||
|
||||
bool MysqlClient::exec(std::string sql)
|
||||
{
|
||||
XLOGD() << "Mysql exec sql=" << sql;
|
||||
//XLOGD() << "Mysql exec sql=" << sql;
|
||||
if (!mysql_)
|
||||
{
|
||||
XLOGE() << "Mysql exec error, database is not connected.";
|
||||
|
||||
Reference in New Issue
Block a user