R/write_table_to_postgres.R

Defines functions write_table_to_postgres

Documented in write_table_to_postgres

#' Write a table using input data to postgres
#' @param tablename character string of the new table name
#' @param input dataframe to be written to table
#' @import DBI
#' @import DatabaseConnector
#' @export

write_table_to_postgres <-
        function(dbname, schema = NULL, tablename, input, port = "5432") {
                conn <- connect_to_local_postgres(dbname = dbname,
                                                  schema = schema,
                                                  port = port)

                DBI::dbWriteTable(conn = conn,
                                  name = tablename,
                                  input)

                DatabaseConnector::disconnect(conn)
        }
patelm9/PosGressive documentation built on Nov. 4, 2019, 11:19 p.m.