View source: R/update_snapshot.R
update_snapshot | R Documentation |
update_snapshots
makes it easy to create and update a historical data table on a remote (SQL) server.
The function takes the data (.data
) as it looks on a given point in time (timestamp
) and then updates
(or creates) an remote table identified by db_table
.
This update only stores the changes between the new data (.data
) and the data currently stored on the remote.
This way, the data can be reconstructed as it looked at any point in time while taking as little space as possible.
See vignette("basic-principles")
for further introduction to the function.
update_snapshot(
.data,
conn,
db_table,
timestamp,
filters = NULL,
message = NULL,
tic = Sys.time(),
logger = NULL,
enforce_chronological_order = TRUE
)
.data |
( |
conn |
( |
db_table |
( |
timestamp |
( |
filters |
( |
message |
( |
tic |
( |
logger |
( |
enforce_chronological_order |
( |
No return value, called for side effects.
filter_keys
conn <- get_connection()
data <- dplyr::copy_to(conn, mtcars)
# Copy the first 3 records
update_snapshot(
head(data, 3),
conn = conn,
db_table = "test.mtcars",
timestamp = Sys.time()
)
# Update with the first 5 records
update_snapshot(
head(data, 5),
conn = conn,
db_table = "test.mtcars",
timestamp = Sys.time()
)
dplyr::tbl(conn, "test.mtcars")
close_connection(conn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.