edbWrite: Write data in a table in a database (referenced by 'edb').

Description Usage Arguments Author(s) See Also Examples

Description

Write data in a table in a database (referenced by 'edb').

Generic function that call class-specific method corresponding

to the class of the edb object provided.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
edbWrite(edb, tableName, data, mode = c("a", "u", "o")[1], 


    pKey = NULL, getKey = NULL, formatCol = NULL, posixFormat = "", 


    dateFormat = "", logOp = FALSE, logRandId = rnorm(1), 


    logMsg = as.character(NA), logTableName = "edbLog", 


    logCreateTableIfNotExist = TRUE, parano = TRUE, 


    ...)

Arguments

edb

An object of class 'edb', such as returned by edb.

tableName

Single character string. Name of the table to read in 'edb'.

data

data.frame. Data to be writen in tableName. If the table

has a PRIMARY KEY, and if it is AUTOINCREMENT, then the column

can be omitted, and the attributed ID's will be retrieved if

!is.null(getKey) (not the default).

mode

Single character string. If "a" (default), the data are

appened to the table (added after the last row), and sRow

is ignored. If "u", the data are updated according to some

critearia in sRow (that can't be NULL). If "o",

the table is overwritten and sRow is ignored.

pKey

Single character string (if mode == "u") or NULL. Column name that

is PRIMARY KEY in the table.

getKey

Single character string or NULL. If non NULL, name of the PRIMARY

KEY whose latest attributed values should be retrieved.

formatCol

If not NULL, a named list of functions to be applied to certain columns

before the data are written to the database. The name of each list

item gives the column to process, and the value of each item gives the

function that must be applied. For instance

formatCol = list("DATE"=as.Date) will apply the function

as.Date to the column "DATE".

posixFormat

Single character string. 'format' argument of the functions

format.POSIXlt() or format.POSIXct() used to convert POSIX

date-time into character strings when writing into the database.

Only used if getKey is not NULL or when mode == "u" in SQLite or

MySQL.

dateFormat

Single character string. 'format' argument of the functions

format.Date() used to convert "Date"

dates into character strings when writing into the database.

Only used if getKey is not NULL or when mode == "u" in SQLite or

MySQL.

logOp

Single logical. If TRUE, then a log of the operation is written

into the database, using the function edbLog.

See the arguments below and edbLog for more details.

logRandId

Single numerical. See edbLog.

logMsg

Single character string. See edbLog.

logTableName

Single character string. See edbLog.

logCreateTableIfNotExist

Single logical. See edbLog.

parano

Single logical. If set to TRUE (the default), the function is

run on "paranoia mode", that is additional tests are performed

before the data are written into the database. This slows down

a bit (more) the function, but it may avoid some mistakes.

...

Additional parameters to be passed to class-specific method. See

methods("edbWrite")

Author(s)

Julien MOEYS <Julien.Moeys@mark.slu.se>

See Also

edb, edbRead,

edbNames, edbColnames.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# See related methods for detailed examples:


# (for example ?edbWrite.RSQLite_SQLite) 


require( "easydb" ) 


methods( "edbWrite" )

easydb documentation built on May 2, 2019, 4:47 p.m.