Load and Install DuckDB/MotherDuck Extensions
load_extensions.RdInstalls (if necessary) and loads valid DuckDB or MotherDuck extensions for the active connection.
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.
Examples
if (FALSE) { # \dontrun{
con <- DBI::dbConnect(duckdb::duckdb())
# Install and load the 'motherduck' extension
load_extensions(con, "motherduck")
# Load multiple extensions
load_extensions(con, c("motherduck", "httpfs"))
DBI::dbDisconnect(con)
} # }