postgresql_uploader: postgresql_uploader

View source: R/postgresql_uploader.R

postgresql_uploaderR Documentation

postgresql_uploader

Description

postgresql_uploader is a convenience function to upload contents of a data.frame object into an exsisting PostgreSQL table. The table must first be created on the PostgreSQL backend (via "⁠CREATE TABLE ...⁠") before postgresql_uploader is used.

killConnections disconnects all PostgreSQL connections.

Usage

postgresql_uploader(
  con,
  r_df,
  pg_table = deparse(substitute(r_df)),
  unique.field.names,
  update = TRUE,
  clean_r_df = TRUE
)

killConnections()

Arguments

con

a DBI::DBIConnection object created with dbConnect.

r_df

data.frame to be uploaded; must contain identical column names to pg_table.

pg_table

character specifying existing PostgreSQL table name; the referred table on the PostgreSQL backend must have the same column names as r_df; pg_table defaults to name of object passed as r_df (i.e. deparse(substitute(r_df))).

unique.field.names

character specifying unique column names as defined in PostgreSQL table constraints (i.e. primary key); please note, that column names of r_df and pg_table must be identical!

update

logical, specifying whether to update existing entries as defined by unique.field.names; defaults to TRUE.

clean_r_df

logical, specifying whether to clean r_df with function cleaner, if duplicates are found; defaults to TRUE, as the PostgreSQL backend will terminate the upload with an error if primary key constraints are violated.

Value

postgresql_uploader returns a list with information about effected inserts and updates

killConnections has no return; its side effect is described above

See Also

dbConnect


joheli/kungfu documentation built on March 25, 2024, 10:10 a.m.