pub struct DbConfig { /* private fields */ }Expand description
Implementations§
Source§impl DbConfig
impl DbConfig
Sourcepub fn new() -> Result<Self, ExtensionError>
pub fn new() -> Result<Self, ExtensionError>
Creates a new, empty DuckDB configuration object.
§Errors
Returns ExtensionError if DuckDB fails to allocate the config
(which is extremely rare in practice).
Sourcepub fn set(self, name: &str, value: &str) -> Result<Self, ExtensionError>
pub fn set(self, name: &str, value: &str) -> Result<Self, ExtensionError>
Sets a single configuration option.
Common options include "access_mode" ("READ_ONLY" / "READ_WRITE"),
"threads" (number of CPU threads), and "memory_limit" (e.g. "1GB").
Use DbConfig::flag_count / DbConfig::get_flag to enumerate all
available options at runtime.
§Unknown option names are accepted here
duckdb_set_config does not reject a name it does not know: it
stores it among the config’s unrecognised options (an extension loaded
later may define it), and the database open that uses this config is
what fails, with unrecognized configuration parameter. Check a name
against flag_count / get_flag
first if you need to catch a typo at this point.
§Errors
Returns ExtensionError if name or value contain interior null bytes,
or if DuckDB rejects the value for an option it recognises (for
example a non-numeric "threads").
Sourcepub fn flag_count() -> usize
pub fn flag_count() -> usize
Returns the total number of available configuration flags.
Use this together with get_flag to enumerate all
configuration options that DuckDB accepts.
Sourcepub fn get_flag(index: usize) -> Result<(String, String), ExtensionError>
pub fn get_flag(index: usize) -> Result<(String, String), ExtensionError>
Returns the name and the second string DuckDB reports for the
configuration flag at index.
For a core option or one of its aliases the second string is the
option’s description. For a setting that belongs to an extension
(s3_region, …) it is the extension’s name ("httpfs"): the third
branch of duckdb_get_config_flag reports entry->extension there,
not a description.
index must be less than flag_count().
§Errors
Returns ExtensionError if index is out of range or DuckDB fails
to retrieve the flag information.