This function sends SQL to the server, and returns the results in an ffdf object.

querySql.ffdf(
  connection,
  sql,
  errorReportFile = file.path(getwd(), "errorReport.txt"),
  snakeCaseToCamelCase = FALSE
)

Arguments

connection

The connection to the database server.

sql

The SQL to be send.

errorReportFile

The file where an error report will be written if an error occurs. Defaults to 'errorReport.txt' in the current working directory.

snakeCaseToCamelCase

If true, field names are assumed to use snake_case, and are converted to camelCase.

Value

A ffdf object containing the data. If there are 0 rows, a regular data frame is returned instead (ffdf cannot have 0 rows).

Details

Retrieves data from the database server and stores it in an ffdf object. This allows very large data sets to be retrieved without running out of memory. If an error occurs during SQL execution, this error is written to a file to facilitate debugging. Null values in the database are converted to NA values in R.

Examples

if (FALSE) { library(ffbase) connectionDetails <- createConnectionDetails(dbms = "postgresql", server = "localhost", user = "root", password = "blah", schema = "cdm_v4") conn <- connect(connectionDetails) count <- querySql.ffdf(conn, "SELECT COUNT(*) FROM person") disconnect(conn) }