mariadb-tables | R Documentation |
These methods read or write entire tables from a MariaDB database.
## S4 method for signature 'MariaDBConnection'
dbAppendTable(conn, name, value, ..., row.names = NULL)
## S4 method for signature 'MariaDBConnection,character'
dbExistsTable(conn, name, ...)
## S4 method for signature 'MariaDBConnection'
dbListObjects(conn, prefix = NULL, ...)
## S4 method for signature 'MariaDBConnection'
dbListTables(conn, ...)
## S4 method for signature 'MariaDBConnection,character'
dbReadTable(conn, name, ..., row.names = FALSE, check.names = TRUE)
## S4 method for signature 'MariaDBConnection,character'
dbRemoveTable(conn, name, ..., temporary = FALSE, fail_if_missing = TRUE)
## S4 method for signature 'MariaDBConnection,character,character'
dbWriteTable(
conn,
name,
value,
field.types = NULL,
overwrite = FALSE,
append = FALSE,
header = TRUE,
row.names = FALSE,
nrows = 50,
sep = ",",
eol = "\n",
skip = 0,
quote = "\"",
temporary = FALSE,
...
)
## S4 method for signature 'MariaDBConnection,character,data.frame'
dbWriteTable(
conn,
name,
value,
field.types = NULL,
row.names = FALSE,
overwrite = FALSE,
append = FALSE,
...,
temporary = FALSE
)
conn |
a MariaDBConnection object, produced by
|
name |
a character string specifying a table name. |
value |
A data frame. |
... |
Unused, needed for compatibility with generic. |
row.names |
Either If A string is equivalent to For backward compatibility, |
prefix |
A fully qualified path in the database's namespace, or |
check.names |
If |
temporary |
If |
fail_if_missing |
If |
field.types |
Optional, overrides default choices of field types, derived from the classes of the columns in the data frame. |
overwrite |
a logical specifying whether to overwrite an existing table
or not. Its default is |
append |
a logical specifying whether to append to an existing table
in the DBMS. If appending, then the table (or temporary table)
must exist, otherwise an error is reported. Its default is |
header |
logical, does the input file have a header line? Default is the
same heuristic used by |
nrows |
number of lines to rows to import using |
sep |
field separator character |
eol |
End-of-line separator |
skip |
number of lines to skip before reading data in the input file. |
quote |
the quote character used in the input file (defaults to
|
When using load_data_local_infile = TRUE
in dbConnect()
,
pass safe = FALSE
to dbAppendTable()
to avoid transactions.
Because LOAD DATA INFILE
is used internally, this means that
rows violating primary key constraints are now silently ignored.
A data.frame in the case of dbReadTable()
; otherwise a logical
indicating whether the operation was successful.
The data.frame returned by dbReadTable()
only has
primitive data, e.g., it does not coerce character data to factors.
Temporary tables are ignored for dbExistsTable()
and dbListTables()
due to
limitations of the underlying C API. For this reason, a prior existence check
is performed only before creating a regular persistent table; an attempt to
create a temporary table with an already existing name will fail with a
message from the database driver.
if (mariadbHasDefault()) {
con <- dbConnect(RMariaDB::MariaDB(), dbname = "test")
# By default, row names are written in a column to row_names, and
# automatically read back into the row.names()
dbWriteTable(con, "mtcars", mtcars[1:5, ], temporary = TRUE)
dbReadTable(con, "mtcars")
dbReadTable(con, "mtcars", row.names = FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.