dbAppendTable | R Documentation |
The dbAppendTable()
method assumes that the table has been created
beforehand, e.g. with dbCreateTable()
.
The default implementation calls sqlAppendTableTemplate()
and then
dbExecute()
with the param
argument.
Use dbAppendTableArrow()
to append data from an Arrow stream.
dbAppendTable(conn, name, value, ..., row.names = NULL)
conn |
A DBIConnection object, as returned by
|
name |
The table name, passed on to
|
value |
A data.frame (or coercible to data.frame). |
... |
Other parameters passed on to methods. |
row.names |
Must be |
Backends compliant to
ANSI SQL 99 which use ?
as a placeholder for prepared queries don't need
to override it. Backends with a different SQL syntax which use ?
as a placeholder for prepared queries can override sqlAppendTable()
.
Other backends (with different placeholders or with entirely different
ways to create tables) need to override the dbAppendTable()
method.
The row.names
argument is not supported by this method.
Process the values with sqlRownamesToColumn()
before calling this method.
dbAppendTable()
returns a
scalar
numeric.
If the table does not exist,
or the new data in values
is not a data frame or has different column names,
an error is raised; the remote table remains unchanged.
An error is raised when calling this method for a closed
or invalid connection.
An error is also raised
if name
cannot be processed with dbQuoteIdentifier()
or
if this results in a non-scalar.
Invalid values for the row.names
argument
(non-scalars,
unsupported data types,
NA
)
also raise an error.
Passing a value
argument different to NULL
to the row.names
argument
(in particular TRUE
,
NA
,
and a string)
raises an error.
SQL keywords can be used freely in table names, column names, and data. Quotes, commas, spaces, and other special characters such as newlines and tabs, can also be used in the data, and, if the database supports non-syntactic identifiers, also for table names and column names.
The following data types must be supported at least,
and be read identically with dbReadTable()
:
integer
numeric
(the behavior for Inf
and NaN
is not specified)
logical
NA
as NULL
64-bit values (using "bigint"
as field type); the result can be
converted to a numeric, which may lose precision,
converted a character vector, which gives the full decimal representation
written to another table and read again unchanged
character (in both UTF-8 and native encodings), supporting empty strings (before and after non-empty strings)
factor (returned as character, with a warning)
list of raw (if supported by the database)
objects of type blob::blob (if supported by the database)
date
(if supported by the database;
returned as Date
)
also for dates prior to 1970 or 1900 or after 2038
time
(if supported by the database;
returned as objects that inherit from difftime
)
timestamp
(if supported by the database;
returned as POSIXct
respecting the time zone but not necessarily preserving the
input time zone),
also for timestamps prior to 1970 or 1900 or after 2038
respecting the time zone but not necessarily preserving the
input time zone)
Mixing column types in the same table is supported.
The name
argument is processed as follows,
to support databases that allow non-syntactic names for their objects:
If an unquoted table name as string: dbAppendTable()
will do the quoting,
perhaps by calling dbQuoteIdentifier(conn, x = name)
If the result of a call to dbQuoteIdentifier()
: no more quoting is done
to support databases that allow non-syntactic names for their objects:
The row.names
argument must be NULL
, the default value.
Row names are ignored.
The value
argument must be a data frame
with a subset of the columns of the existing table.
The order of the columns does not matter.
Other DBIConnection generics:
DBIConnection-class
,
dbAppendTableArrow()
,
dbCreateTable()
,
dbCreateTableArrow()
,
dbDataType()
,
dbDisconnect()
,
dbExecute()
,
dbExistsTable()
,
dbGetException()
,
dbGetInfo()
,
dbGetQuery()
,
dbGetQueryArrow()
,
dbIsReadOnly()
,
dbIsValid()
,
dbListFields()
,
dbListObjects()
,
dbListResults()
,
dbListTables()
,
dbQuoteIdentifier()
,
dbReadTable()
,
dbReadTableArrow()
,
dbRemoveTable()
,
dbSendQuery()
,
dbSendQueryArrow()
,
dbSendStatement()
,
dbUnquoteIdentifier()
,
dbWriteTable()
,
dbWriteTableArrow()
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbCreateTable(con, "iris", iris)
dbAppendTable(con, "iris", iris)
dbReadTable(con, "iris")
dbDisconnect(con)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.