dbGetQuery() always returns a data.frame with as many rows as records were fetched and as many columns as fields in the result set, even if the result is a single value or has one or zero rows. An error is raised when issuing a query over a closed or invalid connection, if the syntax of the query is invalid, or if the query is not a non-NA string. If the n argument is not an atomic whole number greater or equal to -1 or Inf, an error is raised, but a subsequent call to dbGetQuery() with proper n argument succeeds.

Additional arguments

The following arguments are not part of the dbGetQuery() generic (to improve compatibility across backends) but are part of the DBI specification:

  • n (default: -1)

  • params (TBD)

They must be provided as named arguments. See the "Specification" and "Value" sections for details on their usage.


Fetching multi-row queries with one or more columns be default returns the entire result. A value of Inf for the n argument is supported and also returns the full result. If more rows than available are fetched, the result is returned in full without warning. If zero rows are fetched, the columns of the data frame are still fully typed. Fetching fewer rows than available is permitted, no warning is issued.

A column named row_names is treated like any other column.

  • spec_result_get_query
Documentation reproduced from package DBItest, version 1.5-2, License: LGPL (>= 2)

Community examples

Looks like there are no examples yet.