Wrapper function to write data to table in default or custom schema. Returns TRUE if successful, FALSE otherwise.

db.write_table(
  con,
  data,
  table,
  schema = NA,
  append_only = FALSE,
  drop_overwrite = NA
)

Arguments

con

An object that inherits from DBIConnection-class, typically generated by dbConnect()

data

A data.frame, tbl, or other valid SQL data type containing the data to write to the database.

table

A character string specifying the DBMS table name.

schema

A character string specifying the schema in which the table is nested.

append_only

A logical specifying whether the operation is INSERT or UPDATE. Default of append_only = FALSE means execute DELETE on table, and update with new data.

drop_overwrite

A logical specifying whether the operation is DROP and INSERT. This will overwrite any existing field types.

Value

Returns TRUE if the SQL query executes successfully,

FALSE otherwise.

Examples

connection <- connect_sqlite(auto_disconnect = FALSE)

db.write_table(con = connection, table = 'iris', data = iris)
#> Table iris successfully updated 2023-02-19 08:57:32
#> [1] TRUE