dbINSERTx: Insert Multiple Records into an SQL Table

Description Usage Arguments Examples

View source: R/SQLquery.R

Description

Inserts multiple data records into an SQL table directly from a data.frame.

Usage

1
dbINSERTx(con, x, .table, .verbose = FALSE, .dump = FALSE)

Arguments

con

SQL database connection object

x

data.frame object, whose column names correspond to field names, and rows to the records to be inserted.

.table

name of the table into which the recored is inserted

.verbose

verbose level

.dump

logical or character vector that indicates if the insertion query should be only dumped into a file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# connect to sample database
con <- .dbSampleConnection()
dbGetQuery(con, 'SELECT * FROM test')

# insert single record
df <- data.frame(a = 1:3, b = letters[1:3], c = c(1.5, NA, 6.5))
id <- dbINSERTx(con, df, .table = 'test')
id

# query table again
dbGetQuery(con, 'SELECT * FROM test')

# clean up
dbEMPTY(con, 'test')

renozao/dbutils documentation built on May 27, 2019, 5:53 a.m.