Description Usage Arguments Details Value See Also Examples
Read data from a ODBC connection into an ffdf
. This can for example be used to import
large datasets from Oracle, SQLite, MySQL, PostgreSQL, Hive or other SQL databases into R.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | read.odbc.ffdf(
query = NULL,
odbcConnect.args = list(dsn = NULL, uid = "", pwd = ""),
odbcDriverConnect.args = list(connection = ""),
odbcQuery.args = list(),
sqlGetResults.args = list(),
x = NULL,
nrows = -1,
first.rows = NULL,
next.rows = NULL,
levels = NULL,
appendLevels = TRUE,
asffdf_args = list(),
BATCHBYTES = getOption("ffbatchbytes"),
VERBOSE = FALSE,
colClasses = NULL,
transFUN = NULL,
...
)
|
query |
the SQL query to execute on the ODBC connection |
odbcConnect.args |
a list of arguments to pass to ODBC's |
odbcDriverConnect.args |
a list of arguments to pass to ODBC's |
odbcQuery.args |
a list of arguments to pass to ODBC's |
sqlGetResults.args |
a list containing optional parameters which will be passed to |
x |
NULL or an optional ffdf object to which the read records are appended.
See documentation in |
nrows |
Number of rows to read from the query resultset. Default value of -1 reads in all rows. |
first.rows |
chunk size (rows) to read for first chunk from the query resultset |
next.rows |
chunk size (rows) to read sequentially for subsequent chunks from the query resultset. Currently, this must be specified. |
levels |
optional specification of factor levels. A list with as names the names the columns of the data.frame fetched in the first.rows, containing levels of the factors. |
appendLevels |
logical. A vector of permissions to expand levels for factor columns. See documentation in |
asffdf_args |
further arguments passed to |
BATCHBYTES |
integer: bytes allowed for the size of the data.frame storing the result of reading one chunk.
See documentation in |
VERBOSE |
logical: TRUE to verbose timings for each processed chunk (default FALSE). |
colClasses |
See documentation in |
transFUN |
function applied to the data frame after each chunk is retreived by |
... |
optional parameters passed on to transFUN |
Opens up the ODBC connection using RODBC::odbcConnect
or RODBC::odbcDriverConnect
,
sends the query using RODBC::odbcQuery
and retrieves
the results in batches of next.rows rows using RODBC::sqlGetResults
. Heavily borrowed from read.table.ffdf
An ffdf object unless the query returns zero records in which case the function will return the data.frame
returned by sqlGetResults
and possibly transFUN.
read.table.ffdf, read.dbi.ffdf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ##
## Using the sqlite database (smalldb.sqlite3) in the /inst folder of the package
## set up the sqlite ODBC driver (www.stats.ox.ac.uk/pub/bdr/RODBC-manual.pd)
## and call it 'smalltestsqlitedb'
##
## Not run:
require(RODBC)
x <- read.odbc.ffdf(
query = "select * from testdata limit 10000",
odbcConnect.args = list(
dsn="smalltestsqlitedb", uid = "", pwd = "",
believeNRows = FALSE, rows_at_time = 1),
nrows = -1,
first.rows = 100, next.rows = 1000, VERBOSE = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.