Aktualisiere Datenbankkonfiguration und verbessere JSON-Merge-Skript
- Füge neue Felder `host`, `port` und `database` zur Datenbankkonfiguration in `chatconfig.json` hinzu. - Implementiere eine Funktion im `update_config.sh`-Skript, um den `connectstring` zu parsen und die neuen Felder automatisch zu befüllen, falls sie fehlen. - Aktualisiere die `Database`-Klasse, um die neuen Konfigurationsparameter zu verwenden.
This commit is contained in:
@@ -8,16 +8,18 @@ namespace Lib {
|
||||
Database::Database(std::shared_ptr<Config> config)
|
||||
{
|
||||
// Hole Verbindungsdaten aus der Config
|
||||
std::string dbname = config->value("database", "database").asString();
|
||||
std::string user = config->value("database", "user").asString();
|
||||
std::string password = config->value("database", "password").asString();
|
||||
std::string host = config->value("database", "host").asString();
|
||||
std::string database = config->value("database", "database").asString();
|
||||
std::string port = config->value("database", "port").asString();
|
||||
|
||||
std::string conninfo =
|
||||
"dbname=" + dbname +
|
||||
"dbname=" + database +
|
||||
" user=" + user +
|
||||
" password=" + password +
|
||||
" host=" + host;
|
||||
" host=" + host +
|
||||
" port=" + port;
|
||||
|
||||
try {
|
||||
_connection = std::make_unique<pqxx::connection>(conninfo);
|
||||
|
||||
Reference in New Issue
Block a user