20 [[nodiscard]] LIGHTWEIGHT_API std::string Sanitized()
const;
22 LIGHTWEIGHT_API
static std::string SanitizePwd(std::string_view input);
25using SqlConnectionStringMap = std::map<std::string, std::string>;
28LIGHTWEIGHT_API SqlConnectionStringMap ParseConnectionString(
SqlConnectionString const& connectionString);
31LIGHTWEIGHT_API
SqlConnectionString BuildConnectionString(SqlConnectionStringMap
const& map);
36 std::string datasource;
39 std::chrono::seconds timeout { 5 };
46 .value = std::format(
"DSN={};UID={};PWD={};TIMEOUT={}", datasource, username, password, timeout.count())
53using SqlConnectInfo = std::variant<SqlConnectionDataSource, SqlConnectionString>;
56struct LIGHTWEIGHT_API std::formatter<SqlConnectInfo>: std::formatter<std::string>
58 auto format(SqlConnectInfo
const& info, format_context& ctx)
const -> format_context::iterator
60 if (
auto const* dsn = std::get_if<SqlConnectionDataSource>(&info))
62 return formatter<string>::format(std::format(
"DSN={};UID={};PWD={};TIMEOUT={}",
66 dsn->timeout.count()),
69 else if (
auto const* connectionString = std::get_if<SqlConnectionString>(&info))
71 return formatter<string>::format(connectionString->value, ctx);
75 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.