Store connection configuration as key value pairs

Add migration for the sqlite database.
Because the Qt SQL library is a bit hard to work with use sqlite through custom wrapper.
This commit is contained in:
eelke 2025-02-22 19:59:24 +01:00
parent 4caccf1000
commit aac55b0ed1
17 changed files with 276439 additions and 384 deletions

View file

@ -19,10 +19,10 @@ namespace {
{ SslMode::verify_full, "verify-full" }
};
inline const char *valuePtr(const std::string &v)
{
return v.empty() ? nullptr : v.c_str();
}
// inline const char *valuePtr(const std::string &v)
// {
// return v.empty() ? nullptr : v.c_str();
// }
struct {
const char * host = "host";
@ -46,17 +46,16 @@ QString SslModeToString(SslMode sm)
if (e.mode == sm)
return QString::fromUtf8(e.string);
return {};
return {};
}
SslMode StringToSslMode(QString s)
{
SslMode result = SslMode::allow;
for (auto e : SslModeStringTable)
if (e.string == s)
result = e.mode;
return e.mode;
return {};
return SslMode::allow;
}
ConnectionConfig::ConnectionConfig()
@ -297,46 +296,11 @@ QString ConnectionConfig::connectionString() const
// maybe we should prevent empty parameters from staying in the map?
if (!param.second.isEmpty())
{
if (!s.isEmpty())
s += " ";
s += param.first % "=" % escapeConnectionStringValue(param.second);
}
}
// s += "host="
// % escapeConnectionStringValue(m_host)
// % " port="
// % QString::number(m_port)
// % " user="
// % escapeConnectionStringValue(m_user);
// s += " password=";
// s += escapeConnectionStringValue(m_password);
// s += " dbname=";
// s += escapeConnectionStringValue(m_dbname);
// s += " sslmode=";
// s += SslModeToString(m_sslMode);
// if (!m_sslCert.isEmpty())
// {
// s += " sslcert=";
// s += escapeConnectionStringValue(m_sslCert);
// }
// if (!m_sslKey.isEmpty())
// {
// s += " sslkey=";
// s += escapeConnectionStringValue(m_sslKey);
// }
// if (!m_sslRootCert.isEmpty())
// {
// s += " sslrootcrt=";
// s += escapeConnectionStringValue(m_sslRootCert);
// }
// if (!m_sslCrl.isEmpty())
// {
// s += " sslCrl=";
// s += escapeConnectionStringValue(m_sslCrl);
// }
// s += " client_encoding=utf8";
// s += " application_name=";
// s += escapeConnectionStringValue(m_applicationName);
return s;
}