duckdb: Connect to a DuckDB database instance

Description Usage Arguments Value Examples

View source: R/Driver.R

Description

dbConnect() connects to a database instance.

dbDisconnect() closes a DuckDB database connection, optionally shutting down the associated instance.

duckdb() creates or reuses a database instance.

duckdb_shutdown() shuts down a database instance.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## S4 method for signature 'duckdb_driver'
dbConnect(
  drv,
  dbdir = DBDIR_MEMORY,
  ...,
  debug = getOption("duckdb.debug", FALSE),
  read_only = FALSE
)

## S4 method for signature 'duckdb_connection'
dbDisconnect(conn, ..., shutdown = FALSE)

duckdb(dbdir = DBDIR_MEMORY, read_only = FALSE)

duckdb_shutdown(drv)

Arguments

drv

Object returned by duckdb()

dbdir

Location for database files. Should be a path to an existing directory in the file system. With the default, all data is kept in RAM

...

Ignored

debug

Print additional debug information such as queries

read_only

Set to TRUE for read-only operation

conn

A duckdb_connection object

shutdown

Set to TRUE to shut down the DuckDB database instance that this connection refers to.

Value

dbConnect() returns an object of class duckdb_connection.

duckdb() returns an object of class duckdb_driver.

dbDisconnect() and duckdb_shutdown() are called for their side effect.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
drv <- duckdb()
con <- dbConnect(drv)

dbGetQuery(con, "SELECT 'Hello, world!'")

dbDisconnect(con)
duckdb_shutdown(drv)

# Shorter:
con <- dbConnect(duckdb())
dbGetQuery(con, "SELECT 'Hello, world!'")
dbDisconnect(con, shutdown = TRUE)

duckdb documentation built on Dec. 15, 2020, 5:35 p.m.