Skip to contents

Check user authentification using shinymanager library

Create a new table in the database

Usage

db_create_table(
  db,
  table_name = character(),
  dataframe = tibble::tibble(),
  dbms = character(),
  primary_key_col = character(),
  unique_cols = character(),
  not_null_cols = character(),
  text_cols = character()
)

Arguments

db

A DBI database connection object

table_name

Name of the new table in the database (character)

dataframe

Dataframe with table informations (columns names & type of value) (dataframe / tibble)

dbms

Database management system used ("postgres" and "sqlite" supported) (character)

primary_key_col

Character vector containing the primary key columns, to create a PRIMARY KEY constraint (character)

unique_cols

Character vector containing the columns with a UNIQUE contraint (character)

not_null_cols

Character vector containing the columns with a NOT NULL constraint (character)

text_cols

Character vector containing the text columns, to create a column with TEXT type in postgres DBMS (character)

Details

The distinct constraints can be combined (a column can have a constraint UNIQUE and NOT NULL)

Examples

if (FALSE) {
db_create_table(db = db, "my_new_table", tibble::tibble(id = integer(), name = character()), dbms = "postgres",
  primary_key_col = "id")
}