diff --git a/src/common/database.cpp b/src/common/database.cpp index 70f4cfc207a..5ddfc3492f1 100644 --- a/src/common/database.cpp +++ b/src/common/database.cpp @@ -84,7 +84,7 @@ mutex_guarded& 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; @@ -105,10 +105,9 @@ mutex_guarded& db::detail::getState() auto host = settings::get("network.SQL_HOST"); auto port = settings::get("network.SQL_PORT"); auto schema = settings::get("network.SQL_DATABASE"); - auto url = fmt::format("tcp://{}:{}", host, port); + auto url = fmt::format("tcp://{}:{}/{}", host, port, schema); state.connection = std::unique_ptr(driver->connect(url.c_str(), login.c_str(), passwd.c_str())); - state.connection->setSchema(schema.c_str()); } catch (const std::exception& e) {