Skip to contents

Creates a database table given a connection, table name, and:

  • SQL file specifying the table's schema

  • CSV file to seed the table's values

Usage

create_tbl(
  conn,
  tbl_name,
  csv_path = "data-raw/database/CSV",
  sql_path = "data-raw/database/SQL",
  drop_if_exists = TRUE
)

Arguments

conn

database connection

tbl_name

character string representing table name

csv_path

base path (excluding file) to the CSV file

sql_path

base path (excluding file) to the SQL file

drop_if_exists

Should the table be dropped (with CASCADE) if it already exists?

Value

the created database table returned as an R data.frame().

Note

It is assumed that the tbl_name mirrors both the basename of the CSV file and the SQL file (excluding extensions).