mdb-sql is a utility program distributed with MDB Tools. It allows querying of an MDB database using a limited SQL subset language. The supported SQL is intentionally small: single-table queries, no aggregates, and limited WHERE support.

mdb_sql(
  path,
  statement = NULL,
  no_header = FALSE,
  no_footer = FALSE,
  no_pretty_print = FALSE,
  delimiter = "\t",
  input = NULL,
  output = NULL,
  as_text = FALSE
)

Arguments

path

Path to .mdb/.accdb file.

statement

SQL statement text.

no_header

Logical, equivalent to -H/--no-header (for text mode).

Logical, equivalent to -F/--no-footer (for text mode).

no_pretty_print

Logical, equivalent to -p/--no-pretty-print.

delimiter

Delimiter equivalent to -d/--delimiter in plain text mode.

input

Input file equivalent to -i/--input.

output

Output file equivalent to -o/--output.

as_text

Logical; when TRUE, returns CLI-like text output.

Value

data.frame by default, or character scalar in text mode.

Details

In addition to single statements, this wrapper accepts input files similar to mdb-sql -i file, strips go batch terminators, and executes the script one statement at a time.

Examples

db <- mdbr:::.mdb_example_nwind_path()
if (nzchar(db)) {
  mdb_sql(db, "SELECT [ProductID], [ProductName] FROM [Products] LIMIT 3;")
}