Added util.cpp#createConnection
This commit is contained in:
parent
9e63e45236
commit
b0f4842168
@ -22,3 +22,17 @@ embed util::getDefaultEmbed(EmbedType type) {
|
||||
e.set_color(getHexColor(type));
|
||||
return e;
|
||||
}
|
||||
|
||||
sql::Connection *util::createConnection(const json &config) {
|
||||
sql::Driver *driver = sql::mariadb::get_driver_instance();
|
||||
|
||||
sql::SQLString url = "jdbc:" + config["string"].get<std::string>();
|
||||
|
||||
sql::Properties properties({{"user", config["username"].get<std::string>()},
|
||||
{"password", config["password"].get<std::string>()},
|
||||
{"autoReconnect", "true"},
|
||||
{"maxReconnects", "500"}});
|
||||
|
||||
sql::Connection *con = driver->connect(url, properties);
|
||||
return con;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user