Description Usage Arguments Details Value See Also Examples
Write ffdf
data to a database table by using a JDBC connection.
This can for example be used to store large ffdf datasets from R in
Oracle, SQLite, MySQL, PostgreSQL, Hive or other SQL databases.
Mark that for very large datasets, these SQL databases might have tools to speed up by bulk loading.
You might also consider that as an alternative to using this procedure.
1 2 3 4 5 6 7 8 9 10 |
x |
the |
name |
character string with the name of the table to store the data in. Passed on to |
dbConnect.args |
a list of arguments to pass to JDBC's |
RECORDBYTES |
optional integer scalar representing the bytes needed to process a single row of the ffdf |
BATCHBYTES |
integer: bytes allowed for the size of the data.frame storing the result of reading one chunk.
See documentation in |
by |
integer passed on to |
VERBOSE |
logical: TRUE to verbose timings for each processed chunk (default FALSE). |
... |
optional parameters passed on to |
Opens up the JDBC connection using RJDBC::dbConnect
, writes data to the SQL table
using RJDBC::dbWriteTable
by extracting the data in batches from the ffdf
and appending them to the table.
invisible()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ## Not run:
require(ff)
##
## Example query using data in sqlite
##
require(RJDBC)
dbfile <- system.file("smalldb.sqlite3", package="ETLUtils")
drv <- JDBC(driverClass = "org.sqlite.JDBC", classPath = "/usr/local/lib/sqlite-jdbc-3.7.2.jar")
query <- "select * from testdata limit 10000"
x <- read.jdbc.ffdf(query = query,
dbConnect.args = list(drv = drv, url = sprintf("jdbc:sqlite:%s", dbfile)),
first.rows = 100, next.rows = 1000, VERBOSE=TRUE)
write.jdbc.ffdf(x = x, name = "helloworld", row.names = FALSE, overwrite = TRUE,
dbConnect.args = list(drv = drv, url = sprintf("jdbc:sqlite:%s", dbfile)),
by = 1000, VERBOSE=TRUE)
test <- read.jdbc.ffdf(query = "select * from helloworld",
dbConnect.args = list(drv = drv, url = sprintf("jdbc:sqlite:%s", dbfile)))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.