Skip to content

Commit

Permalink
db: Use isValid(int32_t timeout) instead of isValid(void)
Browse files Browse the repository at this point in the history
  • Loading branch information
zach2good committed Dec 20, 2024
1 parent 32ee8de commit 182c637
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mutex_guarded<db::detail::State>& db::detail::getState()
{
// If we have a valid and connected connection: return it
// TODO: Does this logic make ping_connection redundant?
return state.connection != nullptr && (state.connection->isValid() || state.connection->reconnect());
return state.connection != nullptr && (state.connection->isValid(/*seconds*/1) || state.connection->reconnect());
}))
{
return state;
Expand All @@ -105,10 +105,9 @@ mutex_guarded<db::detail::State>& db::detail::getState()
auto host = settings::get<std::string>("network.SQL_HOST");
auto port = settings::get<uint16>("network.SQL_PORT");
auto schema = settings::get<std::string>("network.SQL_DATABASE");
auto url = fmt::format("tcp://{}:{}", host, port);
auto url = fmt::format("tcp://{}:{}/{}", host, port, schema);

state.connection = std::unique_ptr<sql::Connection>(driver->connect(url.c_str(), login.c_str(), passwd.c_str()));
state.connection->setSchema(schema.c_str());
}
catch (const std::exception& e)
{
Expand Down

0 comments on commit 182c637

Please sign in to comment.