Learn R Programming

dbi.table (version 1.0.1)

as.data.table: Coerce to data.table

Description

Execute a dbi.table's underlying SQL query and return the result set as a data.table. By default, the result set is limited to 10,000 rows. See Details.

Usage

# S3 method for dbi.table
as.data.table(
  x,
  keep.rownames = FALSE,
  ...,
  n = getOption("dbi_table_max_fetch", 10000L)
)

Value

a dbi.table.

Arguments

x

a dbi.table.

keep.rownames

a logical value. This argument is not used.

...

additional arguments are ignored.

n

an integer value. When nonnegative, the underlying SQL query includes a 'LIMIT n' clause and n is also passed to dbFetch. When negative, the underlying SQL query does not include a LIMIT clause and all rows in the result set are returned.

Details

By default, as.data.table returns up to 10,000 rows (see the n argument). To override this limit, either call as.data.table and provide the n argument (e.g., n = -1 to return the entire result set), or set the option dbi_table_max_fetch to the desired default value of n.

See Also

as.data.table (the generic method in the data.table package).

Examples

Run this code
  duck <- chinook.duckdb()
  Artist <- dbi.table(duck, DBI::Id("Artist"))

  as.data.table(Artist, n = 7)[]

  DBI::dbDisconnect(duck)

Run the code above in your browser using DataLab