dbFetch_AdbiResult {adbi} | R Documentation |
Fetch result sets
Description
When fetching results using dbFetch()
, the argument n
can be specified
to control chunk size per fetching operation. The default value of -1
corresponds to retrieving the entire result set at once, while a positive
integer will try returning as many rows (as long as n
does not exceed the
available number of rows), in line with standard DBI expectations. As data
transfer is mediated by Arrow data structures, which are retrieved as array
chunks, the underlying chunk size can be used by passing an n
value NA
.
Usage
## S4 method for signature 'AdbiResult'
dbFetch(res, n = -1, ...)
Arguments
res |
An object inheriting from DBIResult, created by
|
n |
maximum number of records to retrieve per fetch. Use |
... |
Other arguments passed on to methods. |
Value
A data.frame
with the requested number of rows (or zero rows if
dbFetch()
is called on a result set with no more remaining rows).
Examples
if (requireNamespace("adbcsqlite")) {
library(DBI)
con <- dbConnect(adbi::adbi("adbcsqlite"), uri = ":memory:")
dbWriteTable(con, "swiss", swiss)
res <- dbSendQuery(con, "SELECT * from swiss WHERE Agriculture < 30")
dbFetch(res)
dbClearResult(res)
dbDisconnect(con)
}