23 [[nodiscard]] LIGHTWEIGHT_API std::string Sanitized()
const;
25 LIGHTWEIGHT_API
static std::string SanitizePwd(std::string_view input);
28using SqlConnectionStringMap = std::map<std::string, std::string>;
31LIGHTWEIGHT_API SqlConnectionStringMap ParseConnectionString(
SqlConnectionString const& connectionString);
34LIGHTWEIGHT_API
SqlConnectionString BuildConnectionString(SqlConnectionStringMap
const& map);
39 std::string datasource;
42 std::chrono::seconds timeout { 5 };
49 .value = std::format(
"DSN={};UID={};PWD={};TIMEOUT={}", datasource, username, password, timeout.count())
56using SqlConnectInfo = std::variant<SqlConnectionDataSource, SqlConnectionString>;
61struct std::formatter<Lightweight::SqlConnectInfo>: std::formatter<std::string>
63 auto format(Lightweight::SqlConnectInfo
const& info, format_context& ctx)
const -> format_context::iterator
65 if (
auto const* dsn = std::get_if<Lightweight::SqlConnectionDataSource>(&info))
67 return formatter<string>::format(
69 "DSN={};UID={};PWD={};TIMEOUT={}", dsn->datasource, dsn->username, dsn->password, dsn->timeout.count()),
72 else if (
auto const* connectionString = std::get_if<Lightweight::SqlConnectionString>(&info))
74 return formatter<string>::format(connectionString->value, ctx);
78 return formatter<string>::format(
"Invalid connection info", ctx);
Represents a connection data source as a DSN, username, password, and timeout.
Represents an ODBC connection string.