to_postgres: Push R Dataframes to Postgres schemas other than Public.

View source: R/to_postgres.R

to_postgresR Documentation

Push R Dataframes to Postgres schemas other than Public.

Description

There some cases where the Postgres servers are set up so that R is not able to build tables in schemas other than public. This function will delete any named tables that exit in both the public schema and the destination schema, then it will re-build the data into public then into the desired schema.

Usage

to_postgres(
  df,
  pg_conn,
  schema_name = "public",
  table_name,
  primary_keys = "NA"
)

Arguments

df

Dataframe that will be pushed to Postgres, required.

pg_conn

required Postgres connection (PqConnection) created from RPostgres::Postgres(). JDBC connections will break this function.

schema_name

string Name of final schema if not public, default is public.

table_name

string Name of new table in Postgres, required.

primary_keys

string Fields to for primary keys, used in a SQL statement, default is NA.

Details

to_postgres() sends df to Postgres with options to create a primary index.

Value

You will get a generic message from RPostgres, check Postgres server for the data to ensure that the data was transferred.

Examples

## Not run: 
to_postgres(df = DF, pg_conn = db_CON, table_name = "data_upload", schema_name = "prod",
primary_keys = "group,date")

## End(Not run)


Fredo-XVII/RToolShed documentation built on March 17, 2024, 12:15 p.m.