Skip to contents

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.

Usage

create_table(
  .data,
  .con,
  database_name,
  schema_name,
  table_name,
  write_type = "overwrite"
)

Arguments

.data

Tibble/data frame (in-memory) or a dbplyr/DBI-backed lazy table (class "tbl_dbi").

.con

A valid DBI connection (DuckDB / MotherDuck).

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: "overwrite" (drop/create) or "append" (insert rows). Defaults to "overwrite".

Value

Invisibly returns NULL. Side effect: writes a table to the database by delegating to the appropriate helper.

Details

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