From d130b9501acb85f1195a20abdd967b29a1dd717b Mon Sep 17 00:00:00 2001 From: Wang Fenjin Date: Sat, 30 Sep 2023 23:07:35 +0800 Subject: [PATCH] add autoload extension config api (#214) * add autoload extension config api * add test --- src/config.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/config.rs b/src/config.rs index 6e89a734..d002a9c9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -52,6 +52,13 @@ impl Config { self.config.unwrap_or(std::ptr::null_mut() as ffi::duckdb_config) } + /// enable autoload extensions + pub fn enable_autoload_extension(mut self, enabled: bool) -> Result { + self.set("autoinstall_known_extensions", &(enabled as i32).to_string())?; + self.set("autoload_known_extensions", &(enabled as i32).to_string())?; + Ok(self) + } + /// Access mode of the database ([AUTOMATIC], READ_ONLY or READ_WRITE) pub fn access_mode(mut self, mode: AccessMode) -> Result { self.set("access_mode", &mode.to_string())?; @@ -174,6 +181,7 @@ mod test { .default_order(crate::DefaultOrder::Desc)? .enable_external_access(true)? .enable_object_cache(false)? + .enable_autoload_extension(true)? .allow_unsigned_extensions()? .max_memory("2GB")? .threads(4)?;