| dbWriteTable,TrinoConnection,ANY-method | R Documentation |
Creates the table with dbCreateTable() and fills it with
dbAppendTable(). CREATE TABLE cannot be undone by dbRollback() on
most connectors, so overwrite = TRUE plays it safe on its own: it
renames the existing table rather than dropping it, and restores it if
anything fails before the new table is fully written.
## S4 method for signature 'TrinoConnection,ANY'
dbWriteTable(
conn,
name,
value,
...,
overwrite = FALSE,
append = FALSE,
field.types = NULL,
temporary = FALSE,
row.names = NULL,
chunk_size = 1000L
)
## S4 method for signature 'TrinoConnection,Id'
dbWriteTable(conn, name, value, ...)
conn |
A TrinoConnection object. |
name |
Table name, in any form |
value |
A data frame to write. |
... |
Unused, for compatibility with the generic. |
overwrite |
Drop and recreate the table if it already exists. |
append |
Add to the table if it already exists, instead of creating it. |
field.types |
A named character vector of Trino types, overriding
the types |
temporary |
Must be |
row.names |
Unused: RTrino never writes row names as a column. |
chunk_size |
Passed to |
TRUE, invisibly.
con <- DBI::dbConnect(RTrino::Trino(), host = Sys.getenv("RTRINO_TEST_URL"),
catalog = "memory", schema = "default")
DBI::dbWriteTable(con, "sales", data.frame(id = 1:3, label = letters[1:3]))
DBI::dbWriteTable(con, "sales", data.frame(id = 4L, label = "d"),
append = TRUE)
DBI::dbGetQuery(con, "SELECT * FROM sales ORDER BY id")
# Replace the table and its contents
DBI::dbWriteTable(con, "sales", data.frame(id = 9L, label = "z"),
overwrite = TRUE)
DBI::dbGetQuery(con, "SELECT * FROM sales")
DBI::dbRemoveTable(con, "sales")
DBI::dbDisconnect(con)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.