diff --git a/lib/src/ConfigLoader.cc b/lib/src/ConfigLoader.cc index 07b85622..5bcbd105 100644 --- a/lib/src/ConfigLoader.cc +++ b/lib/src/ConfigLoader.cc @@ -231,9 +231,9 @@ static void loadApp(const Json::Value &app) } static void loadDbClients(const Json::Value &dbClients) { -#if USE_ORM if (!dbClients) return; +#if USE_ORM for (auto &client : dbClients) { auto type = client.get("rdbms", "postgresql").asString(); @@ -252,6 +252,9 @@ static void loadDbClients(const Json::Value &dbClients) auto filename = client.get("filename", "").asString(); drogon::app().createDbClient(type, host, (u_short)port, dbname, user, password, connNum, filename, name); } +#else + std::cout << "No database is supported by drogon, please install the database development library first." << std::endl; + exit(1); #endif } static void loadListeners(const Json::Value &listeners) diff --git a/lib/src/HttpAppFrameworkImpl.cc b/lib/src/HttpAppFrameworkImpl.cc index 9029ba3b..c4f11202 100755 --- a/lib/src/HttpAppFrameworkImpl.cc +++ b/lib/src/HttpAppFrameworkImpl.cc @@ -1277,6 +1277,9 @@ void HttpAppFrameworkImpl::createDbClient(const std::string &dbType, #if USE_POSTGRESQL auto client = drogon::orm::DbClient::newPgClient(connStr, connectionNum); _dbClientsMap[name] = client; +#else + std::cout << "The PostgreSQL is not supported by drogon, please install the development library first." << std::endl; + exit(1); #endif } else if (type == "mysql") @@ -1284,6 +1287,9 @@ void HttpAppFrameworkImpl::createDbClient(const std::string &dbType, #if USE_MYSQL auto client = drogon::orm::DbClient::newMysqlClient(connStr, connectionNum); _dbClientsMap[name] = client; +#else + std::cout << "The Mysql is not supported by drogon, please install the development library first." << std::endl; + exit(1); #endif } else if (type == "sqlite3") @@ -1292,6 +1298,9 @@ void HttpAppFrameworkImpl::createDbClient(const std::string &dbType, std::string sqlite3ConnStr = "filename=" + filename; auto client = drogon::orm::DbClient::newSqlite3Client(sqlite3ConnStr, connectionNum); _dbClientsMap[name] = client; +#else + std::cout << "The Sqlite3 is not supported by drogon, please install the development library first." << std::endl; + exit(1); #endif } }