Learn R Programming

motherduck (version 0.2.0)

load_extensions: Load and Install DuckDB/MotherDuck Extensions

Description

Installs (if necessary) and loads valid DuckDB or MotherDuck extensions for the active connection.

Usage

load_extensions(.con, extension_names)

Value

Invisibly returns NULL. The function prints a CLI report of the extension status.

Arguments

.con

A valid DBI connection (DuckDB / MotherDuck).

extension_names

A character vector of DuckDB/MotherDuck extension names to load/install.

Details

The load_extensions() function first validates the provided DuckDB/MotherDuck connection, then checks which of the requested extensions are valid and not already installed. Valid extensions are installed and loaded into the current session. Invalid extensions are reported to the user. The function provides a detailed CLI report summarizing which extensions were successfully installed and loaded, and which were invalid.

It is especially useful for ensuring that required extensions, such as motherduck, are available in your database session. The CLI messages also provide guidance on listing all available extensions and installing additional DuckDB extensions.

See Also

Other db-con: install_extensions(), show_motherduck_token(), validate_extension_install_status(), validate_extension_load_status()

Examples

Run this code
if (FALSE) {
con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile()))

# Install and load the 'motherduck' extension
load_extensions(con, "motherduck")

# Load multiple extensions
load_extensions(con, c("motherduck", "httpfs"))

DBI::dbDisconnect(con)
}

Run the code above in your browser using DataLab