Modify the signature of the createDbClient() method

This commit is contained in:
antao 2019-01-07 16:26:58 +08:00
parent 468fcf13e0
commit 5ea972e5b3
5 changed files with 12 additions and 9 deletions

View File

@ -189,8 +189,8 @@ class HttpAppFramework : public trantor::NonCopyable
const std::string &userName,
const std::string &password,
const size_t connectionNum = 1,
const std::string &name = "default",
const std::string &filename = "") = 0;
const std::string &filename = "",
const std::string &name = "default") = 0;
#endif
private:

View File

@ -250,7 +250,7 @@ static void loadDbClients(const Json::Value &dbClients)
auto connNum = client.get("connection_number", 1).asUInt();
auto name = client.get("name", "default").asString();
auto filename = client.get("filename", "").asString();
drogon::app().createDbClient(type, host, (u_short)port, dbname, user, password, connNum, name, filename);
drogon::app().createDbClient(type, host, (u_short)port, dbname, user, password, connNum, filename, name);
}
#endif
}

View File

@ -1261,8 +1261,8 @@ void HttpAppFrameworkImpl::createDbClient(const std::string &dbType,
const std::string &userName,
const std::string &password,
const size_t connectionNum,
const std::string &name,
const std::string &filename)
const std::string &filename,
const std::string &name)
{
auto connStr = formattedString("host=%s port=%u dbname=%s user=%s", host.c_str(), port, databaseName.c_str(), userName.c_str());
if (!password.empty())

View File

@ -105,8 +105,8 @@ class HttpAppFrameworkImpl : public HttpAppFramework
const std::string &userName,
const std::string &password,
const size_t connectionNum = 1,
const std::string &name = "default",
const std::string &filename = "") override;
const std::string &filename = "",
const std::string &name = "default") override;
#endif
private:
virtual void registerHttpController(const std::string &pathPattern,

View File

@ -1,4 +1,5 @@
#include "Groups.h"
#include <drogon/drogon.h>
#include <drogon/orm/DbClient.h>
#include <trantor/utils/Logger.h>
#include <iostream>
@ -8,9 +9,11 @@ using namespace drogon::orm;
int main()
{
trantor::Logger::setLogLevel(trantor::Logger::TRACE);
auto clientPtr = DbClient::newSqlite3Client("filename=test.db", 3);
drogon::app().createDbClient("sqlite3", "", 0, "", "", "", 3, "test.db");
//auto clientPtr = DbClient::newSqlite3Client("filename=test.db", 3);
sleep(3);
sleep(1);
auto clientPtr = app().getDbClient();
LOG_DEBUG << "start!";
// *clientPtr << "Drop table groups;" << Mode::Blocking >>
// [](const Result &r) {