Skip to contents

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.

Usage

upload_database_to_md(.con, from_db_name, to_db_name)

Arguments

.con

A valid DBI connection (DuckDB / MotherDuck).

from_db_name

The local database name to copy from.

to_db_name

The target MotherDuck database to create/overwrite.

Value

Invisibly returns NULL. Side effect: creates the target database and copies all objects; prints a CLI action report.

Details

  • 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.

Examples

if (FALSE) { # \dontrun{
con_db <- DBI::dbConnect(duckdb::duckdb())
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")
} # }