26constexpr std::size_t PrefetchDepthDefault = 1000;
35inline constexpr std::size_t PreparedStatementCacheCapacityDefault = 0;
39inline constexpr std::size_t PreparedStatementCacheCapacitySuggested = 64;
77[[nodiscard]] LIGHTWEIGHT_API
SqlEncryptionMode ParseEncryptionMode(std::string_view value)
noexcept;
84[[nodiscard]] LIGHTWEIGHT_API std::string_view FormatEncryptionMode(
SqlEncryptionMode mode)
noexcept;
97 [[nodiscard]] LIGHTWEIGHT_API std::string
Sanitized()
const;
111 [[nodiscard]] LIGHTWEIGHT_API
static std::string
SanitizePwd(std::string_view input);
114using SqlConnectionStringMap = std::map<std::string, std::string>;
121LIGHTWEIGHT_API SqlConnectionStringMap ParseConnectionString(
SqlConnectionString const& connectionString);
127LIGHTWEIGHT_API
SqlConnectionString BuildConnectionString(SqlConnectionStringMap
const& map);
140[[nodiscard]] LIGHTWEIGHT_API std::string FormatConnectionStringValue(std::string_view value);
154[[nodiscard]] LIGHTWEIGHT_API
bool EnsureSqliteDatabaseFileExists(
SqlConnectionString const& connectionString);
167 std::chrono::seconds timeout { 5 };
174 std::size_t defaultPrefetchDepth = PrefetchDepthDefault;
189 std::size_t preparedStatementCacheCapacity = PreparedStatementCacheCapacityDefault;
209using SqlConnectInfo = std::variant<SqlConnectionDataSource, SqlConnectionString>;
214struct std::formatter<Lightweight::SqlConnectInfo>: std::formatter<std::string>
216 auto format(Lightweight::SqlConnectInfo
const& info, format_context& ctx)
const -> format_context::iterator
218 if (
auto const* dsn = std::get_if<Lightweight::SqlConnectionDataSource>(&info))
220 return formatter<string>::format(dsn->ToConnectionString().value, ctx);
222 else if (
auto const* connectionString = std::get_if<Lightweight::SqlConnectionString>(&info))
224 return formatter<string>::format(connectionString->value, ctx);
228 return formatter<string>::format(
"Invalid connection info", ctx);
SqlEncryptionMode
Whether the client/server connection is TLS-encrypted.
@ Enabled
Request an encrypted connection (SQL_EN_ON).
@ Disabled
Request an unencrypted connection (SQL_EN_OFF).
auto operator<=>(SqlConnectionDataSource const &) const noexcept=default
Three-way comparison operator.
static LIGHTWEIGHT_API SqlConnectionDataSource FromConnectionString(SqlConnectionString const &value)
Constructs a SqlConnectionDataSource from the given connection string.
LIGHTWEIGHT_API SqlConnectionString ToConnectionString() const
std::string datasource
The ODBC data source name (DSN).
std::string password
The password for authentication.
std::string username
The username for authentication.
auto operator<=>(SqlConnectionString const &) const noexcept=default
Three-way comparison operator.
static LIGHTWEIGHT_API std::string SanitizePwd(std::string_view input)
std::string value
The raw ODBC connection string value.
LIGHTWEIGHT_API std::string Sanitized() const
Returns a copy of the connection string with every password value masked, see SanitizePwd.