dbWriteTable2: Data Import Wrapper for dbWriteTable.

View source: R/database.R

dbWriteTable2R Documentation

Data Import Wrapper for dbWriteTable.

Description

This is wrapper for dbWriteTable written with the the primary improvements focusing on database import into an existing table definition schema. The function matches and rearranges columns of the dataframe to database feilds and additionally performs checks for NA's in required variables, overlength strings, and type mismatches. There also exists support for updating of the PostgreSQL specific sequence for tables with auto incrementing primary keys.

Usage

dbWriteTable2(con, table.name, df, fill.null = TRUE, add.id=TRUE, 
                   row.names=FALSE, pg.update.seq=FALSE, ...)

Arguments

con

connection.

table.name

The name of the table to which the data frame is to be loaded.

df

A dataframe to be loaded to the database.

fill.null

Should new db present fields be added to the data.frame before it is loaded?.

add.id

Should a new column should be added for the database id?

row.names

Should the row names be loaded as a seperate column? (unlike the original dbWriteTable, default is FALSE)

pg.update.seq

should the table primary key's sequence be updated to the highest id value +1? (Postgres specific)

...

other parameters passed to dbWriteTable.

Value

If successful, the ids of the newly added database records (invisible)

See Also

dbWriteTable


caroline documentation built on Oct. 21, 2024, 9:06 a.m.