| Title: | Utilities for Managing a 'Motherduck' Database |
|---|---|
| Description: | Provides helper functions, metadata utilities, and workflows for administering and managing 'DuckDB' databases on the 'MotherDuck' cloud platform. Some features require a 'MotherDuck' account (<https://motherduck.com/>). Note: Windows is not supported; use 'WSL' (Windows Subsystem for Linux) instead (<https://motherduck.com/docs/integrations/language-apis-and-drivers/r/>). |
| Authors: | Alejandro Hagan [aut, cre] |
| Maintainer: | Alejandro Hagan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.3 |
| Built: | 2026-05-31 10:37:24 UTC |
| Source: | https://github.com/usrbinr/motherduck |
Moves one or more tables from an existing schema to a new (target) schema
using ALTER TABLE ... SET SCHEMA. If the target schema does not exist,
it is created first.
alter_table_schema(.con, table_names, from_schema, new_schema, silent = FALSE)alter_table_schema(.con, table_names, from_schema, new_schema, silent = FALSE)
.con |
A valid |
table_names |
Character vector of table names to move. |
from_schema |
Source schema name (where the tables currently reside). |
new_schema |
Target schema name (where the tables will be moved). |
silent |
Logical; if |
Ensures new_schema exists (CREATE SCHEMA IF NOT EXISTS).
For each table in table_names, runs:
ALTER TABLE from_schema.table SET SCHEMA new_schema.
Table and schema identifiers are safely quoted with glue::glue_sql().
Invisibly returns NULL.
Side effects: creates new_schema if needed and moves tables.
Other db-manage:
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_and_create_schema(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
Switches the active database and (optionally) schema for a valid
DuckDB or MotherDuck connection. The function validates the target
database and schema before executing the USE command and provides
user feedback via CLI messages.
cd(.con, database_name, schema_name, silent = FALSE)cd(.con, database_name, schema_name, silent = FALSE)
.con |
A valid |
database_name |
A character string specifying the database to switch to.
Must be one of the available databases returned by |
schema_name |
(Optional) A character string specifying the schema
to switch to within the given database. Must be one of the available
schemas returned by |
silent |
to print message or not, default is FALSE |
The cd() function is analogous to a "change directory" command in a
file system, but for database contexts. It updates the currently active
database (and optionally schema) for the given connection. If the target
database or schema does not exist, the function aborts with a descriptive
CLI error message.
Invisibly returns a message summarizing the new connection context. Side effects include printing CLI headers showing the current user and database context.
Other db-meta:
launch_ui(),
pwd(),
summary()
## Not run: # Connect to MotherDuck con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # List available databases list_databases(con) # Change to a specific database and schema cd(con, database_name = "analytics_db", schema_name = "public") # Disconnect DBI::dbDisconnect(con) ## End(Not run)## Not run: # Connect to MotherDuck con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # List available databases list_databases(con) # Change to a specific database and schema cd(con, database_name = "analytics_db", schema_name = "public") # Disconnect DBI::dbDisconnect(con) ## End(Not run)
A named character list of DuckDB CSV reading configuration settings used
by the package. This includes options such as type detection, delimiter,
quote handling, sample size, and other parser flags. These reflect the
values returned by config_csv.
config_csvconfig_csv
A named character list. Example names include:
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; types used for detection
character; buffer size in bytes
character; column names/types struct or empty
character; delimiter string
character; number of lines to skip
## Not run: config_csv$all_varchar ## End(Not run)## Not run: config_csv$all_varchar ## End(Not run)
A named character list of DuckDB runtime configuration settings used by the package.
This object includes allocator settings, thread counts, extension flags, storage and checkpoint options,
security and secret settings, and other engine-level options. These settings reflect the values returned by
config_db and are suitable as a template or reference for configuring DuckDB instances created via the package.
config_dbconfig_db
A named character list. Example names and values include:
character; e.g. "automatic"
character; "true"/"false"
character; e.g. "512MB"
character; e.g. "128MB"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; URL or empty string
character; "true"/"false"
character; "true"/"false"
character; path to certificate file, or empty string
character; numeric as string, e.g. "100"
character; e.g. "16MB"
character; e.g. "16MB"
character; URL or empty string
character; string or empty
character; e.g. "262144"
character; collation name or empty
character; e.g. "NULLS_LAST"
character; e.g. "NULLS_LAST"
character; e.g. "ASC"
character; e.g. "local_file"
character; list or empty
character; e.g. "cli"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; path or empty
character; numeric as string, e.g. "1"
character; "true"/"false"
character; "true"/"false"
character; numeric as string, e.g. "2048"
character; numeric as string, e.g. "0.001"
character; "true"/"false"
character; numeric as string, e.g. "100"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; "true"/"false"
character; path for persistent secrets
character; e.g. "v0.10.2"
character; path or empty string
character; number of threads as string, e.g. "4"
character; number of threads as string, e.g. "4"
character; string or empty
character; string or empty
character; numeric as string, e.g. "4096"
# inspect the config config_db # access individual settings config_db$threads# inspect the config config_db # access individual settings config_db$threads
A named character list of DuckDB Excel reading configuration settings
used by the package. Includes options such as reading binary as string,
adding filename/row_number columns, Hive partitioning, and union by name.
These reflect the values returned by config_excel.
config_excelconfig_excel
A named character list. Example names include:
character; "true"/"false"
character; encryption struct or "-" if none
character; "true"/"false"
character; "true"/"false"
character; e.g., "(auto-detect)"
character; "true"/"false"
## Not run: config_excel$binary_as_string ## End(Not run)## Not run: config_excel$binary_as_string ## End(Not run)
A named character list of DuckDB Parquet reading configuration settings
used by the package. Includes options such as binary encoding, filename
columns, row numbers, and union by name. Reflects config_parquet.
config_parquetconfig_parquet
A named character list. Example names include:
character; "true"/"false"
character; encryption struct or "-" if none
character; "true"/"false"
character; "true"/"false"
character; e.g., "(auto-detect)"
character; "true"/"false"
## Not run: config_parquet$binary_as_string ## End(Not run)## Not run: config_parquet$binary_as_string ## End(Not run)
Updates a MotherDuck user's configuration settings, including token type, instance size, and flock size. This function uses the MotherDuck REST API to apply the changes for the specified user.
configure_md_user_settings( user_name, token_type = "read_write", instance_size = "pulse", flock_size = 0 )configure_md_user_settings( user_name, token_type = "read_write", instance_size = "pulse", flock_size = 0 )
user_name |
Character. The username of the MotherDuck user to configure. |
token_type |
Character. The type of access token for the user; must be
|
instance_size |
Character. The instance size for the user; must be one of
|
flock_size |
Numeric. The flock size for the user; must be a whole number between 0 and 60 (default: 0). |
This function validates each parameter before making a PUT request to the
MotherDuck API. It ensures that:
token_type is valid using validate_token_type().
instance_size is valid using validate_instance_size().
flock_size is a valid integer using validate_flock_size().
Uses the token from the MOTHERDUCK_TOKEN environment variable for
authorization.
A tibble containing the API response, including the updated settings for the user.
Other db-api:
create_md_access_token(),
create_md_user(),
delete_md_access_token(),
delete_md_user(),
list_md_active_accounts(),
list_md_user_instance(),
list_md_user_tokens(),
show_current_user()
## Not run: configure_md_user_settings( user_name = "alice", token_type = "read_write", instance_size = "pulse", flock_size = 10 ) ## End(Not run)## Not run: configure_md_user_settings( user_name = "alice", token_type = "read_write", instance_size = "pulse", flock_size = 10 ) ## End(Not run)
Establishes a connection to a MotherDuck account using DuckDB and the MotherDuck extension.
The function handles token validation, database file creation, extension loading, and executes
PRAGMA MD_CONNECT to authenticate the connection.
connect_to_motherduck(db_path = NULL, config)connect_to_motherduck(db_path = NULL, config)
db_path |
Character, optional. Path to a DuckDB database file or directory to use. If
|
config |
List, optional. A list of DuckDB configuration options to be passed to
|
This function provides a convenient interface for connecting to MotherDuck. It:
Uses the token from the MOTHERDUCK_TOKEN environment variable.
Optionally specifies a persistent DuckDB database file or directory via db_path.
Optionally provides custom DuckDB configuration options via config.
Automatically loads the MotherDuck extension if not already loaded.
You must set the MOTHERDUCK_TOKEN environment variable in your .Renviron file
before calling this function. Use usethis::edit_r_environ() to edit your
.Renviron file.
If db_path is not supplied, a temporary DuckDB database file will be created in the session's
temporary directory. Use config to pass any DuckDB-specific options (e.g., memory limits or
extensions).
MotherDuck currently supports DuckDB versions 1.3.0 through 1.4.4. This function will warn if you're using an untested version.
A DBIConnection object connected to your MotherDuck account.
## Not run: # Connect using a token stored in your .Renviron con <- connect_to_motherduck() # Connect and specify a persistent database file con <- connect_to_motherduck(db_path = "~/my_database.duckdb") ## End(Not run)## Not run: # Connect using a token stored in your .Renviron con <- connect_to_motherduck() # Connect and specify a persistent database file con <- connect_to_motherduck(db_path = "~/my_database.duckdb") ## End(Not run)
Copies one or more tables to a new location (database/schema) by creating
new tables via CREATE TABLE ... AS SELECT * FROM ....
Requires motherduck connection
copy_tables_to_new_location( .con, from_table_names, to_database_name, to_schema_name )copy_tables_to_new_location( .con, from_table_names, to_database_name, to_schema_name )
.con |
A valid |
from_table_names |
A tibble/data frame listing source tables, with
columns |
to_database_name |
Target database name. |
to_schema_name |
Target schema name. |
Input from_table_names must contain columns:
database_name, schema_name, and table_name.
For each source table, the function issues:
CREATE TABLE <to_db>.<to_schema>.<table> AS SELECT * FROM <src_db>.<src_schema>.<table>.
On local DuckDB (non-MotherDuck), the target database name is ignored and defaults to the current database of the connection.
Invisibly returns a character vector of fully-qualified destination table names that were created. Side effect: creates target DB/schema if needed and writes new tables.
Other db-manage:
alter_table_schema(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_and_create_schema(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
Ensures a database exists and sets it as the active database.
If connected to MotherDuck, the function will run
CREATE DATABASE IF NOT EXISTS followed by USE <database>.
Prints CLI status information about the current user and database.
create_database(.con, database_name)create_database(.con, database_name)
.con |
A valid |
database_name |
Name of the database to create/ensure and switch to |
Connection type is checked via validate_md_connection_status()
(with return_type = "arg").
On MotherDuck, executes:
CREATE DATABASE IF NOT EXISTS <database>
USE <database>
Displays status and environment info with CLI messages.
Invisibly returns NULL.
Side effect: may create a database and switches to it; prints CLI status
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_and_create_schema(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
## Not run: con_md <- connect_to_motherduck() create_database(con_md, "analytics") ## End(Not run)## Not run: con_md <- connect_to_motherduck() create_database(con_md, "analytics") ## End(Not run)
Creates a new access token for a specified MotherDuck user using the REST API. Tokens can be configured with a specific type, name, and expiration time.
create_md_access_token( user_name, token_type, token_name, token_expiration_number, token_expiration_unit )create_md_access_token( user_name, token_type, token_name, token_expiration_number, token_expiration_unit )
user_name |
A character string specifying the MotherDuck user name whose tokens should be listed. |
token_type |
Character. The type of token to create. Must be one of:
|
token_name |
Character. A descriptive name for the token. |
token_expiration_number |
Numeric. The duration of the token's validity,
in the units specified by |
token_expiration_unit |
Character. The unit of time for the token expiration.
One of |
This function calls the MotherDuck REST API endpoint
https://api.motherduck.com/v1/users/{user_name}/tokens to create a new token
for the specified user. The token's time-to-live (TTL) is calculated in seconds
from token_expiration_number and token_expiration_unit.
Uses the token from the MOTHERDUCK_TOKEN environment variable for
authorization. The authenticated user must have administrative privileges.
A tibble containing the API response, including the username and the token attributes.
Other db-api:
configure_md_user_settings(),
create_md_user(),
delete_md_access_token(),
delete_md_user(),
list_md_active_accounts(),
list_md_user_instance(),
list_md_user_tokens(),
show_current_user()
## Not run: # Create a temporary read/write token for user "alejandro_hagan" valid for 1 hour create_md_access_token( user_name = "alejandro_hagan", token_type = "read_write", token_name = "temp_token", token_expiration_number = 1, token_expiration_unit = "hours" ) ## End(Not run)## Not run: # Create a temporary read/write token for user "alejandro_hagan" valid for 1 hour create_md_access_token( user_name = "alejandro_hagan", token_type = "read_write", token_name = "temp_token", token_expiration_number = 1, token_expiration_unit = "hours" ) ## End(Not run)
Sends a POST request to the MotherDuck REST API to create a new user
within your organization. This operation requires administrative privileges.
create_md_user(user_name)create_md_user(user_name)
user_name |
A character string specifying the MotherDuck user name whose tokens should be listed. |
This function calls the
MotherDuck Users API
endpoint to create a new user under the authenticated account.
The token from the MOTHERDUCK_TOKEN environment variable must belong to
a user with permissions to manage organization-level accounts.
A tibble summarizing the API response, typically containing the newly created username and associated metadata.
Other db-api:
configure_md_user_settings(),
create_md_access_token(),
delete_md_access_token(),
delete_md_user(),
list_md_active_accounts(),
list_md_user_instance(),
list_md_user_tokens(),
show_current_user()
## Not run: # Create a new user in MotherDuck create_md_user("new_user_name") ## End(Not run)## Not run: # Create a new user in MotherDuck create_md_user("new_user_name") ## End(Not run)
Ensures that a specified schema exists in the given database. If the connection is to a MotherDuck instance, the function switches to the specified database before creating the schema. It also prints helpful connection and environment information via CLI messages for transparency.
create_schema(.con, database_name, schema_name)create_schema(.con, database_name, schema_name)
.con |
A valid |
database_name |
Name of the database to create/use. |
schema_name |
Name of the schema to create if it does not exist. |
Uses DBI::dbExecute() with CREATE SCHEMA IF NOT EXISTS to create
the schema only when needed.
If connected to MotherDuck (determined by
validate_md_connection_status()), executes USE <database> before
creating the schema.
Displays connection/user/database information via internal CLI helpers.
Invisibly returns NULL.
Side effect: creates the schema if necessary and prints CLI messages.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_table(),
delete_and_create_schema(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
A thin wrapper that routes to either create_table_dbi() (for
dbplyr-backed lazy tables, class "tbl_dbi") or
create_table_tbl() (for in-memory tibbles / data frames), creating
a physical table in the target database/schema. Supports overwrite
and append write strategies and defers all heavy lifting to the
specific implementation.
create_table( .data, .con, database_name, schema_name, table_name, write_type = "overwrite" )create_table( .data, .con, database_name, schema_name, table_name, write_type = "overwrite" )
.data |
Tibble/data frame (in-memory) or a |
.con |
A valid |
database_name |
Database name to create/use. |
schema_name |
Schema name to create/use. |
table_name |
Target table name to create or append to. |
write_type |
Write strategy: |
If .data is a dbplyr lazy table (class "tbl_dbi"), the call is
delegated to create_table_dbi().
If .data is an in-memory tibble/data frame (class including
"data.frame"), the call is delegated to create_table_tbl().
Any other input classes trigger an error.
Invisibly returns NULL. Side effect: writes a table to the database by
delegating to the appropriate helper.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
delete_and_create_schema(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
Drops an existing schema (if it exists) in the specified database and then creates a new empty schema. If the connection is to a MotherDuck instance, the function switches to the given database first, then drops and recreates the schema. Displays helpful CLI output about the current connection, user, and database.
delete_and_create_schema(.con, database_name, schema_name)delete_and_create_schema(.con, database_name, schema_name)
.con |
A valid |
database_name |
The name of the database where the schema should be dropped and recreated. |
schema_name |
The name of the schema to drop and recreate. |
Executes DROP SCHEMA IF EXISTS ... CASCADE to remove an existing schema
and all contained objects.
Executes CREATE SCHEMA IF NOT EXISTS to recreate it.
If connected to MotherDuck (detected by
validate_md_connection_status()), performs a USE <database> first.
Prints a summary of the current connection and schema creation status using internal CLI helpers.
Invisibly returns NULL.
Side effect: drops and recreates the schema and prints CLI status messages.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
Drops a database from the current DuckDB or MotherDuck connection if it exists. Prints a CLI status report after performing the operation.
delete_database(.con, database_name)delete_database(.con, database_name)
.con |
A valid |
database_name |
Name of the database to drop. |
Executes DROP DATABASE IF EXISTS <database_name> to remove the database.
Intended for DuckDB or MotherDuck connections.
Prints user, database and action details using CLI helper functions.
Invisibly returns NULL.
Side effect: drops the database and prints CLI status messages.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_and_create_schema(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
Deletes a specific access token for a given MotherDuck user using the REST API. This operation requires administrative privileges.
delete_md_access_token(user_name, token_name)delete_md_access_token(user_name, token_name)
user_name |
A character string specifying the MotherDuck user name whose tokens should be listed. |
token_name |
Character. The name of the access token to delete. |
This function calls the MotherDuck REST API endpoint
https://api.motherduck.com/v1/users/{user_name}/tokens/{token_name}
using a DELETE request to remove the specified token.
Uses the token from the MOTHERDUCK_TOKEN environment variable for
authorization. The authenticated user must have sufficient permissions
to perform token management.
A tibble summarizing the API response, typically including the username and deletion status of the token.
Other db-api:
configure_md_user_settings(),
create_md_access_token(),
create_md_user(),
delete_md_user(),
list_md_active_accounts(),
list_md_user_instance(),
list_md_user_tokens(),
show_current_user()
## Not run: # Delete a token named "temp_token" for user "alejandro_hagan" delete_md_access_token( user_name = "alejandro_hagan", token_name = "temp_token" ) ## End(Not run)## Not run: # Delete a token named "temp_token" for user "alejandro_hagan" delete_md_access_token( user_name = "alejandro_hagan", token_name = "temp_token" ) ## End(Not run)
Sends a DELETE request to the MotherDuck REST API to permanently remove a user
from your organization. This operation requires administrative privileges.
delete_md_user(user_name)delete_md_user(user_name)
user_name |
A character string specifying the MotherDuck user name whose tokens should be listed. |
This function calls the
MotherDuck Users API
endpoint to delete the specified user. The authenticated user (via the
MOTHERDUCK_TOKEN environment variable) must have sufficient permissions
to perform user management actions.
A tibble summarizing the API response, including the username and deletion status.
Other db-api:
configure_md_user_settings(),
create_md_access_token(),
create_md_user(),
delete_md_access_token(),
list_md_active_accounts(),
list_md_user_instance(),
list_md_user_tokens(),
show_current_user()
## Not run: # Delete a user named "bob_smith" delete_md_user("bob_smith") ## End(Not run)## Not run: # Delete a user named "bob_smith" delete_md_user("bob_smith") ## End(Not run)
Drops a schema from a specified database. Optionally cascades the deletion to all objects within the schema. Prints helpful CLI information about the current connection and action.
delete_schema(.con, database_name, schema_name, cascade = FALSE)delete_schema(.con, database_name, schema_name, cascade = FALSE)
.con |
A valid |
database_name |
Name of the database containing the schema. |
schema_name |
Name of the schema to drop. |
cascade |
Logical; if |
Runs DROP SCHEMA IF EXISTS <db>.<schema> with optional CASCADE.
Intended for DuckDB or MotherDuck connections.
Uses CLI helpers to show current connection and report the deletion.
Invisibly returns NULL.
Side effect: drops the schema (and contained objects if cascade = TRUE)
and prints CLI status.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_and_create_schema(),
delete_database(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
Drops a table from the specified database and schema if it exists.
Uses DROP TABLE IF EXISTS for safety and prints a CLI status report.
delete_table(.con, database_name, schema_name, table_name)delete_table(.con, database_name, schema_name, table_name)
.con |
A valid |
database_name |
Name of the database containing the table. |
schema_name |
Name of the schema containing the table. |
table_name |
Name of the table to drop. |
Invisibly returns NULL.
Side effect: drops the table and prints CLI status messages.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_and_create_schema(),
delete_database(),
delete_schema(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares(),
upload_database_to_md()
Installs valid DuckDB or MotherDuck extensions for the current connection.
install_extensions(.con, extension_names)install_extensions(.con, extension_names)
.con |
A valid |
extension_names |
A character vector of DuckDB/MotherDuck extension names to install. |
The install_extensions() function validates the provided DuckDB/MotherDuck connection,
then checks which of the requested extensions are valid. Valid extensions that are not
already installed are installed using the INSTALL SQL command. Invalid extensions are
reported to the user via CLI messages. This function provides a summary report
describing which extensions were successfully installed and which were invalid.
Unlike load_extensions(), this function focuses purely on installation and does not
automatically load extensions after installing.
Invisibly returns NULL. A detailed CLI report of installation success/failure
is printed.
Other db-con:
load_extensions(),
show_motherduck_token(),
validate_extension_install_status(),
validate_extension_load_status()
## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Install the 'motherduck' extension install_extensions(con, "motherduck") # Install multiple extensions install_extensions(con, c("fts", "httpfs")) DBI::dbDisconnect(con) ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Install the 'motherduck' extension install_extensions(con, "motherduck") # Install multiple extensions install_extensions(con, c("fts", "httpfs")) DBI::dbDisconnect(con) ## End(Not run)
The launch_ui() function installs and launches the DuckDB UI extension
for an active DuckDB database connection. This allows users to interact
with the database via a web-based graphical interface.
The function will check that the connection is valid before proceeding.
launch_ui(.con)launch_ui(.con)
.con |
A valid |
The function performs the following steps:
Checks that the provided DuckDB connection is valid. If the connection is invalid, it aborts with a descriptive error message.
Installs the ui extension into the connected DuckDB instance.
Calls the start_ui() procedure to launch the DuckDB UI in your browser.
This provides a convenient way to explore and manage DuckDB databases interactively without needing to leave the R environment.
The function is called for its side effects and does not return a value. It launches the DuckDB UI and opens it in your default web browser.
Other db-meta:
cd(),
pwd(),
summary()
## Not run: # Connect to DuckDB con_db <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Launch the DuckDB UI launch_ui(con_db) # Clean up DBI::dbDisconnect(con_db, shutdown = TRUE) ## End(Not run)## Not run: # Connect to DuckDB con_db <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Launch the DuckDB UI launch_ui(con_db) # Clean up DBI::dbDisconnect(con_db, shutdown = TRUE) ## End(Not run)
Returns a lazy tibble of distinct database (catalog) names visible through
the current connection, using information_schema.tables.
list_all_databases(.con)list_all_databases(.con)
.con |
A valid |
The result is a dbplyr lazy table (tbl_dbi). Use dplyr::collect() to bring
results into R as a local tibble.
A dbplyr lazy tibble with one column: table_catalog.
Other db-list:
list_all_tables(),
list_current_schemas(),
list_current_tables(),
list_extensions(),
list_fns(),
list_setting(),
list_shares()
Returns a lazy tibble of all tables visible to the current connection by
querying information_schema.tables (across all catalogs/databases and
schemas).
list_all_tables(.con)list_all_tables(.con)
.con |
A valid |
The result is a dbplyr lazy table (tbl_dbi). Use collect() to bring
results into R as a local tibble.
A dbplyr lazy tibble with columns:
table_catalog — database/catalog name
table_schema — schema name
table_name — table name
Other db-list:
list_all_databases(),
list_current_schemas(),
list_current_tables(),
list_extensions(),
list_fns(),
list_setting(),
list_shares()
Returns a lazy tibble of all schemas in the current database of the
connection. Queries information_schema.schemata and filters to the
current database (catalog_name = current_database()).
list_current_schemas(.con)list_current_schemas(.con)
.con |
A valid |
This function assumes the connection is valid (checked with
validate_con()).
Returns a dbplyr lazy table; use collect() to bring the result into R.
A dbplyr lazy tibble with columns:
catalog_name — the current database name.
schema_name — each schema within that database.
Other db-list:
list_all_databases(),
list_all_tables(),
list_current_tables(),
list_extensions(),
list_fns(),
list_setting(),
list_shares()
Returns a lazy tibble of all tables that exist in the current database
and current schema of the active connection.
Queries the standard information_schema.tables view and filters to
current_database() and current_schema().
list_current_tables(.con)list_current_tables(.con)
.con |
A valid |
This function validates that the connection is valid with validate_con().
Result is a dbplyr lazy table (tbl_dbi); call collect() to bring it
into R.
A dbplyr lazy tibble with columns:
table_catalog — the current database.
table_schema — the current schema.
table_name — each table name.
Other db-list:
list_all_databases(),
list_all_tables(),
list_current_schemas(),
list_extensions(),
list_fns(),
list_setting(),
list_shares()
Retrieves all available DuckDB or MotherDuck extensions along with their descriptions, installation and load status.
list_extensions(.con)list_extensions(.con)
.con |
A valid |
The list_extensions() function queries the database for all extensions that are
available in the current DuckDB or MotherDuck connection. The returned tibble includes
information such as:
extension_name: Name of the extension.
description: Short description of the extension.
installed: Logical indicating if the extension is installed.
loaded: Logical indicating if the extension is currently loaded.
This is useful for determining which extensions can be installed or loaded using
install_extensions() or load_extensions().
A tibble with one row per extension and columns describing its metadata and current status.
Other db-list:
list_all_databases(),
list_all_tables(),
list_current_schemas(),
list_current_tables(),
list_fns(),
list_setting(),
list_shares()
## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # List all available extensions list_extensions(con) DBI::dbDisconnect(con) ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # List all available extensions list_extensions(con) DBI::dbDisconnect(con) ## End(Not run)
Returns a lazy table listing available SQL functions from the current
DuckDB/MotherDuck connection using duckdb_functions().
list_fns(.con)list_fns(.con)
.con |
A valid |
This wrapper validates the connection and then queries
duckdb_functions() to enumerate function metadata. The result is a
dbplyr lazy tibble (tbl_dbi); call collect() to materialize it in R.
A dbplyr lazy tibble (tbl_dbi) with function metadata (e.g.,
function_name, schema, is_aggregate, is_alias, etc.).
Other db-list:
list_all_databases(),
list_all_tables(),
list_current_schemas(),
list_current_tables(),
list_extensions(),
list_setting(),
list_shares()
Retrieves a list of active MotherDuck accounts available to the authenticated user, returning the results as a tidy tibble.
list_md_active_accounts()list_md_active_accounts()
This function queries the MotherDuck REST API endpoint
(https://api.motherduck.com/v1/active_accounts) using the token from
the MOTHERDUCK_TOKEN environment variable.
A tibble with two columns:
account_settings: configuration keys for the active accounts.
account_values: corresponding configuration values.
Other db-api:
configure_md_user_settings(),
create_md_access_token(),
create_md_user(),
delete_md_access_token(),
delete_md_user(),
list_md_user_instance(),
list_md_user_tokens(),
show_current_user()
## Not run: # Retrieve active accounts for the authenticated user accounts_tbl <- list_md_active_accounts() print(accounts_tbl) ## End(Not run)## Not run: # Retrieve active accounts for the authenticated user accounts_tbl <- list_md_active_accounts() print(accounts_tbl) ## End(Not run)
Retrieves configuration and instance-level settings for a specified MotherDuck user, returning the results as a tidy tibble.
list_md_user_instance(user_name)list_md_user_instance(user_name)
user_name |
A character string specifying the MotherDuck user name whose tokens should be listed. |
This function calls the MotherDuck REST API endpoint
https://api.motherduck.com/v1/users/{user_name}/instances to fetch
information about the user's active DuckDB instances and their configuration
parameters.
Uses the token from the MOTHERDUCK_TOKEN environment variable for
authorization.
A tibble with two columns:
instance_desc: names or descriptions of instance configuration settings.
instance_values: corresponding values for each configuration field.
Other db-api:
configure_md_user_settings(),
create_md_access_token(),
create_md_user(),
delete_md_access_token(),
delete_md_user(),
list_md_active_accounts(),
list_md_user_tokens(),
show_current_user()
## Not run: # List instance settings for a specific user instance_tbl <- list_md_user_instance(user_name = "bob_smith") ## End(Not run)## Not run: # List instance settings for a specific user instance_tbl <- list_md_user_instance(user_name = "bob_smith") ## End(Not run)
Retrieves all active authentication tokens associated with a specific MotherDuck user account, returning them as a tidy tibble.
list_md_user_tokens(user_name)list_md_user_tokens(user_name)
user_name |
A character string specifying the MotherDuck user name whose tokens should be listed. |
This function queries the MotherDuck REST API endpoint
https://api.motherduck.com/v1/users/{user_name}/tokens to list the tokens
available for the specified user.
Uses the token from the MOTHERDUCK_TOKEN environment variable for
authorization.
A tibble with two columns:
token_settings: metadata fields associated with each token.
token_values: corresponding values for those fields.
Other db-api:
configure_md_user_settings(),
create_md_access_token(),
create_md_user(),
delete_md_access_token(),
delete_md_user(),
list_md_active_accounts(),
list_md_user_instance(),
show_current_user()
## Not run: # List tokens for a specific user tokens_tbl <- list_md_user_tokens(user_name = "alejandro_hagan") print(tokens_tbl) ## End(Not run)## Not run: # List tokens for a specific user tokens_tbl <- list_md_user_tokens(user_name = "alejandro_hagan") print(tokens_tbl) ## End(Not run)
The list_setting() function provides a convenient way to inspect the
active configuration of a DuckDB or MotherDuck connection. It executes
the internal DuckDB function duckdb_settings() and returns the results
as a tidy tibble for easy viewing or filtering.
list_setting(.con)list_setting(.con)
.con |
A valid |
This function is particularly useful for debugging or auditing runtime environments. All settings are returned as character columns, including their names, current values, and default values.
A tibble::tibble containing one row per setting with columns describing the setting name, current value, description, and default value.
Other db-list:
list_all_databases(),
list_all_tables(),
list_current_schemas(),
list_current_tables(),
list_extensions(),
list_fns(),
list_shares()
## Not run: # Connect to DuckDB con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # List all database settings list_setting(con) # Disconnect DBI::dbDisconnect(con) ## End(Not run)## Not run: # Connect to DuckDB con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # List all database settings list_setting(con) # Disconnect DBI::dbDisconnect(con) ## End(Not run)
Installs (if necessary) and loads valid DuckDB or MotherDuck extensions for the active connection.
load_extensions(.con, extension_names)load_extensions(.con, extension_names)
.con |
A valid |
extension_names |
A character vector of DuckDB/MotherDuck extension names to load/install. |
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.
Invisibly returns NULL. The function prints a CLI report of the extension status.
Other db-con:
install_extensions(),
show_motherduck_token(),
validate_extension_install_status(),
validate_extension_load_status()
## Not run: 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) ## End(Not run)## Not run: 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) ## End(Not run)
Displays the current database, schema, and role for the active DuckDB/MotherDuck connection.
This mirrors the behavior of pwd in Linux by showing your current “working database.”
pwd(.con, silent = FALSE)pwd(.con, silent = FALSE)
.con |
A valid |
silent |
to print message or not, default is FALSE |
The pwd() function is a helper for inspecting the current database context of a DuckDB
or MotherDuck connection. It queries the database for the current database, schema, and role.
The database and schema are returned as a tibble for easy programmatic access, while the
role is displayed using a CLI alert. This is especially useful in multi-database environments
or when working with different user roles, providing a quick way to verify where SQL queries
will be executed.
A tibble with columns:
The active database name.
The active schema name.
The current role is printed to the console via cli.
Other db-meta:
cd(),
launch_ui(),
summary()
## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) pwd(con) ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) pwd(con) ## End(Not run)
Loads the DuckDB excel extension and creates a table from a CSV file
using the read_csv_auto() table function. The destination is fully qualified
as <database>.<schema>.<table>. Only the options you supply are forwarded
to read_csv_auto() (e.g., header, all_varchar, sample_size,
names, types, skip, union_by_name, normalize_names,
allow_quoted_nulls, ignore_errors). If names or types are not supplied,
they are ignored. See the DuckDB read_csv_auto() documentation for more information.
read_csv( .con, to_database_name, to_schema_name, to_table_name, file_path, header, all_varchar, sample_size, names, types, skip, union_by_name, normalize_names, allow_quoted_nulls, ignore_errors, write_type, ... )read_csv( .con, to_database_name, to_schema_name, to_table_name, file_path, header, all_varchar, sample_size, names, types, skip, union_by_name, normalize_names, allow_quoted_nulls, ignore_errors, write_type, ... )
.con |
A valid |
to_database_name |
Target database name (new or existing) |
to_schema_name |
Target schema name (new or existing) |
to_table_name |
Target table name to create (new or existing) |
file_path |
Path to the Excel file ( |
header |
Logical; if |
all_varchar |
Logical; coerce all columns to |
sample_size |
Numeric; number of rows used for type inference |
names |
Character vector; optional column names to assign instead of reading from the file |
types |
Named or unnamed character vector; column types (named preferred, unnamed paired to |
skip |
Integer; number of rows to skip at the beginning of the file |
union_by_name |
Logical; union multiple CSVs by column name |
normalize_names |
Logical; normalize column names (lowercase, replace spaces) |
allow_quoted_nulls |
Logical; treat |
ignore_errors |
Logical; continue on row parse errors |
write_type |
Character; either |
... |
Additional arguments passed to |
Invisibly returns NULL. Side effect: creates <database>.<schema>.<table> with the CSV data
Other db-read:
read_excel()
Loads the DuckDB excel extension and creates a table from an Excel file
using the read_xlsx() table function. The destination is fully qualified
as <database>.<schema>.<table>. Only the options you supply are forwarded
to read_xlsx() (e.g., sheet, header, all_varchar, ignore_errors,
range, stop_at_empty, empty_as_varchar).
See 'duckdb extension read_excel for more information
read_excel( .con, to_database_name, to_schema_name, to_table_name, file_path, header, sheet, all_varchar, ignore_errors, range, stop_at_empty, empty_as_varchar, write_type )read_excel( .con, to_database_name, to_schema_name, to_table_name, file_path, header, sheet, all_varchar, ignore_errors, range, stop_at_empty, empty_as_varchar, write_type )
.con |
A valid |
to_database_name |
Target database name (new or existing) |
to_schema_name |
Target schema name (new or existing) |
to_table_name |
Target table name to create (new or existing) |
file_path |
Path to the Excel file ( |
header |
Logical; if |
sheet |
Character; sheet name to read (defaults to first sheet) |
all_varchar |
Logical; coerce all columns to |
ignore_errors |
Logical; continue on cell/row errors |
range |
Character; Excel range like |
stop_at_empty |
Logical; stop at first completely empty row |
empty_as_varchar |
Logical; treat empty columns as |
write_type |
Logical, will drop previous table and replace with new table |
Invisibly returns NULL.
Side effect: creates <database>.<schema>.<table> with the Excel data.
Other db-read:
read_csv()
Return or print the current database user for a MotherDuck / DuckDB connection.
show_current_user(.con, return = "msg")show_current_user(.con, return = "msg")
.con |
A valid |
return |
Character scalar, one of |
This helper queries the active DB connection for the current user (via
SELECT current_user).
The function supports two output modes:
"msg" — prints a small informative message and returns the result
invisibly (useful for interactive use),
"arg" — returns a tibble containing the current_user column.
a tibble
Other db-api:
configure_md_user_settings(),
create_md_access_token(),
create_md_user(),
delete_md_access_token(),
delete_md_user(),
list_md_active_accounts(),
list_md_user_instance(),
list_md_user_tokens()
## Not run: # Using an existing connection con <- connect_to_motherduck() show_current_user(.con = con, return = "msg") ## End(Not run)## Not run: # Using an existing connection con <- connect_to_motherduck() show_current_user(.con = con, return = "msg") ## End(Not run)
List all schemas available in the connected database.
This function queries the information_schema.schemata view to return
metadata about schemas that exist in the database associated with the
provided DBI connection. It is intended for inspection and debugging
purposes and does not modify database state.
show_information_schema(.con)show_information_schema(.con)
.con |
A valid |
The structure and contents of the returned tibble depend on the database
backend. Databases may expose additional or fewer columns in
information_schema.schemata.
A tibble with one row per schema. Columns typically include catalog name, schema name, schema owner, and other database-specific metadata as defined by the SQL information schema.
## Not run: library(DBI) con <- dbConnect(duckdb::duckdb()) show_information_schema(con) dbDisconnect(con, shutdown = TRUE) ## End(Not run)## Not run: library(DBI) con <- dbConnect(duckdb::duckdb()) show_information_schema(con) dbDisconnect(con, shutdown = TRUE) ## End(Not run)
Displays the active MotherDuck authentication token associated with the current connection. Useful for debugging or verifying that your session is authenticated correctly.
show_motherduck_token(.con)show_motherduck_token(.con)
.con |
A valid |
The show_motherduck_token() function executes the internal MotherDuck pragma
print_md_token and returns the token information. This function should only be
used in secure environments, as it exposes your authentication token in plain text.
It requires a valid MotherDuck connection established with DBI::dbConnect().
A tibble containing the current MotherDuck token.
Other db-con:
install_extensions(),
load_extensions(),
validate_extension_install_status(),
validate_extension_load_status()
## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) show_motherduck_token(con) DBI::dbDisconnect(con) ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) show_motherduck_token(con) DBI::dbDisconnect(con) ## End(Not run)
The summary.tbl_lazy() method provides a database-aware summary interface
for lazy tables created via dbplyr. Instead of collecting data into R,
it constructs a SQL SUMMARIZE query and executes it remotely, returning
another lazy table reference.
## S3 method for class 'tbl_lazy' summary(object, ...)## S3 method for class 'tbl_lazy' summary(object, ...)
object |
A |
... |
Additional arguments (currently unused). Present for S3 method compatibility. |
This method does not pull data into memory. Instead, it creates a new
lazy query object representing the database-side summary. To retrieve the
summarized data, use collect() on the returned object.
A tbl_lazy object containing the summarized results,
still backed by the remote database connection.
Other db-meta:
cd(),
launch_ui(),
pwd()
## Not run: library(DBI) library(duckdb) library(dplyr) con <- dbConnect(duckdb::duckdb(dbdir = tempfile())) dbWriteTable(con, "mtcars", mtcars) tbl_obj <- tbl(con, "mtcars") # Returns a lazy summary table summary(tbl_obj) dbDisconnect(con) ## End(Not run)## Not run: library(DBI) library(duckdb) library(dplyr) con <- dbConnect(duckdb::duckdb(dbdir = tempfile())) dbWriteTable(con, "mtcars", mtcars) tbl_obj <- tbl(con, "mtcars") # Returns a lazy summary table summary(tbl_obj) dbDisconnect(con) ## End(Not run)
Creates a new database on MotherDuck (if it does not exist) and copies
all objects from an existing local database into it using the
COPY FROM DATABASE command.
upload_database_to_md(.con, from_db_name, to_db_name)upload_database_to_md(.con, from_db_name, to_db_name)
.con |
A valid |
from_db_name |
The local database name to copy from. |
to_db_name |
The target MotherDuck database to create/overwrite. |
Runs CREATE DATABASE <to_db_name> if the target database does not exist.
Then runs COPY FROM DATABASE <from_db_name> TO <to_db_name> to copy all
objects (tables, views, etc.) from the local database.
Prints a CLI status report (connection, user, current DB) after completion.
Invisibly returns NULL.
Side effect: creates the target database and copies all objects; prints a CLI
action report.
Other db-manage:
alter_table_schema(),
copy_tables_to_new_location(),
create_database(),
create_if_not_exists_share(),
create_or_replace_share(),
create_schema(),
create_table(),
delete_and_create_schema(),
delete_database(),
delete_schema(),
delete_table(),
describe_share(),
drop_share(),
list_owned_shares(),
list_shared_with_me_shares()
## Not run: con_db <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) create_table(.con=con_db,.data=mtcars,database_name="memory",schema_name="main",table_name="mtcars") con_md <- connect_to_motherduck() upload_database_to_md(con_md, from_db_name = "memory", to_db_name = "analytics") ## End(Not run)## Not run: con_db <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) create_table(.con=con_db,.data=mtcars,database_name="memory",schema_name="main",table_name="mtcars") con_md <- connect_to_motherduck() upload_database_to_md(con_md, from_db_name = "memory", to_db_name = "analytics") ## End(Not run)
Validates that your connection object is a DuckDB connection
validate_con(.con)validate_con(.con)
.con |
A valid |
logical value or error message
## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_duckdb_con(con) ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_duckdb_con(con) ## End(Not run)
Checks whether a database with the specified name exists on the current connection.
validate_database_exists(.con, database_name)validate_database_exists(.con, database_name)
.con |
A valid |
database_name |
A string specifying the database name to check. |
This function queries the available databases for the connection using
motherduck::list_all_databases() and performs an exact match check.
Returns TRUE if the database exists, FALSE otherwise.
Logical TRUE if the database exists, FALSE otherwise.
## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_database_exists(con, "test_db") ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_database_exists(con, "test_db") ## End(Not run)
Checks whether a schema with the specified name exists within a given database.
validate_database_schema_exists(.con, database_name, target_schema)validate_database_schema_exists(.con, database_name, target_schema)
.con |
A valid |
database_name |
The database name to check. |
target_schema |
The schema name to check within the database. |
This function queries the information schema to check if the specified schema exists within the given database.
Logical TRUE if the schema exists, FALSE otherwise.
## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_database_schema_exists(con, "memory", "main") ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_database_schema_exists(con, "memory", "main") ## End(Not run)
Checks whether specified DuckDB or MotherDuck extensions are installed and provides a detailed status report.
validate_extension_install_status(.con, extension_names, return_type = "msg")validate_extension_install_status(.con, extension_names, return_type = "msg")
.con |
A valid |
extension_names |
A character vector of extensions to validate. |
return_type |
One of
|
The validate_extension_install_status() function validates the current connection and
checks which of the requested extensions are installed. It produces a detailed CLI report
showing which extensions are installed, not installed, or missing.
The function can return different outputs based on the return_type argument:
"msg": prints a CLI report with extension statuses.
"ext": returns a list containing success_ext (installed) and fail_ext (not installed).
"arg": returns a logical value indicating whether all requested extensions are installed.
Depending on return_type:
"msg": prints CLI messages (invisible NULL).
"ext": list with success_ext and fail_ext.
"arg": logical indicating if all requested extensions are installed.
Other db-con:
install_extensions(),
load_extensions(),
show_motherduck_token(),
validate_extension_load_status()
## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Print CLI report validate_extension_install_status(con, extension_names = c("arrow", "excel"), return_type = "msg") # Return a list of installed and failed extensions validate_extension_install_status(con, extension_names = c("arrow", "excel"), return_type = "ext") # Return logical indicating if all requested extensions are installed validate_extension_install_status(con, extension_names = c("arrow", "excel"), return_type = "arg") ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Print CLI report validate_extension_install_status(con, extension_names = c("arrow", "excel"), return_type = "msg") # Return a list of installed and failed extensions validate_extension_install_status(con, extension_names = c("arrow", "excel"), return_type = "ext") # Return logical indicating if all requested extensions are installed validate_extension_install_status(con, extension_names = c("arrow", "excel"), return_type = "arg") ## End(Not run)
Checks whether specified DuckDB or MotherDuck extensions are loaded in the current session and provides a detailed status report.
validate_extension_load_status(.con, extension_names, return_type = "msg")validate_extension_load_status(.con, extension_names, return_type = "msg")
.con |
A valid |
extension_names |
A character vector of extensions to validate. |
return_type |
One of
|
The validate_extension_load_status() function validates the current connection, then
checks which of the requested extensions are loaded. It produces a detailed CLI report
showing which extensions are loaded, failed to load, or missing.
Depending on the return_type argument, the function can either print messages, return
a list of extension statuses, or return a logical value indicating whether all requested
extensions are successfully loaded.
Depending on return_type:
"msg": prints CLI messages (invisible NULL).
"ext": list with success_ext, fail_ext, and missing_ext.
"arg": logical indicating if all requested extensions are loaded.
Other db-con:
install_extensions(),
load_extensions(),
show_motherduck_token(),
validate_extension_install_status()
## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Print CLI report validate_extension_load_status(con, extension_names = c("excel", "arrow"), return_type = "msg") # Return a list of loaded, failed, and missing extensions validate_extension_load_status(con, extension_names = c("excel", "arrow"), return_type = "ext") # Return logical indicating if all requested extensions are loaded validate_extension_load_status(con, extension_names = c("excel", "arrow"), return_type = "arg") ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb(dbdir = tempfile())) # Print CLI report validate_extension_load_status(con, extension_names = c("excel", "arrow"), return_type = "msg") # Return a list of loaded, failed, and missing extensions validate_extension_load_status(con, extension_names = c("excel", "arrow"), return_type = "ext") # Return logical indicating if all requested extensions are loaded validate_extension_load_status(con, extension_names = c("excel", "arrow"), return_type = "arg") ## End(Not run)
Validates if you are successfully connected to motherduck database and will return either a logical value or print a message
validate_md_connection_status(.con, return_type = "msg")validate_md_connection_status(.con, return_type = "msg")
.con |
A valid |
return_type |
return message or logical value of connection status |
logical value or warning message
## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_md_connection_status(con) ## End(Not run)## Not run: con <- DBI::dbConnect(duckdb::duckdb()) validate_md_connection_status(con) ## End(Not run)