-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathduckdb.Rd
123 lines (99 loc) · 4.18 KB
/
duckdb.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Driver.R, R/dbConnect__duckdb_driver.R,
% R/dbDisconnect__duckdb_connection.R
\name{duckdb}
\alias{duckdb}
\alias{duckdb_shutdown}
\alias{duckdb_adbc}
\alias{dbConnect__duckdb_driver}
\alias{dbConnect,duckdb_driver-method}
\alias{dbDisconnect__duckdb_connection}
\alias{dbDisconnect,duckdb_connection-method}
\title{Connect to a DuckDB database instance}
\usage{
duckdb(
dbdir = DBDIR_MEMORY,
read_only = FALSE,
bigint = "numeric",
config = list()
)
duckdb_shutdown(drv)
duckdb_adbc()
\S4method{dbConnect}{duckdb_driver}(
drv,
dbdir = DBDIR_MEMORY,
...,
debug = getOption("duckdb.debug", FALSE),
read_only = FALSE,
timezone_out = "UTC",
tz_out_convert = c("with", "force"),
config = list(),
bigint = "numeric"
)
\S4method{dbDisconnect}{duckdb_connection}(conn, ..., shutdown = TRUE)
}
\arguments{
\item{dbdir}{Location for database files. Should be a path to an existing
directory in the file system. With the default (or \code{""}), all
data is kept in RAM.}
\item{read_only}{Set to \code{TRUE} for read-only operation.
For file-based databases, this is only applied when the database file is opened for the first time.
Subsequent connections (via the same \code{drv} object or a \code{drv} object pointing to the same path)
will silently ignore this flag.}
\item{bigint}{How 64-bit integers should be returned. There are two options: \code{"numeric"} and \code{"integer64"}.
If \code{"numeric"} is selected, bigint integers will be treated as double/numeric.
If \code{"integer64"} is selected, bigint integers will be set to bit64 encoding.}
\item{config}{Named list with DuckDB configuration flags, see
\url{https://duckdb.org/docs/configuration/overview#configuration-reference} for the possible options.
These flags are only applied when the database object is instantiated.
Subsequent connections will silently ignore these flags.}
\item{drv}{Object returned by \code{duckdb()}}
\item{...}{Ignored}
\item{debug}{Print additional debug information such as queries}
\item{timezone_out}{The time zone returned to R, defaults to \code{"UTC"}, which
is currently the only timezone supported by duckdb.
If you want to display datetime values in the local timezone,
set to \code{\link[=Sys.timezone]{Sys.timezone()}} or \code{""}.}
\item{tz_out_convert}{How to convert timestamp columns to the timezone specified
in \code{timezone_out}. There are two options: \code{"with"}, and \code{"force"}. If \code{"with"}
is chosen, the timestamp will be returned as it would appear in the specified time zone.
If \code{"force"} is chosen, the timestamp will have the same clock
time as the timestamp in the database, but with the new time zone.}
\item{conn}{A \code{duckdb_connection} object}
\item{shutdown}{Unused. The database instance is shut down automatically.}
}
\value{
\code{duckdb()} returns an object of class \linkS4class{duckdb_driver}.
\code{dbDisconnect()} and \code{duckdb_shutdown()} are called for their
side effect.
An object of class "adbc_driver"
\code{dbConnect()} returns an object of class
\linkS4class{duckdb_connection}.
}
\description{
\code{duckdb()} creates or reuses a database instance.
\code{duckdb_shutdown()} shuts down a database instance.
Return an \code{\link[adbcdrivermanager:adbc_driver]{adbcdrivermanager::adbc_driver()}} for use with Arrow Database
Connectivity via the adbcdrivermanager package.
\code{dbConnect()} connects to a database instance.
\code{dbDisconnect()} closes a DuckDB database connection.
The associated DuckDB database instance is shut down automatically,
it is no longer necessary to set \code{shutdown = TRUE} or to call \code{duckdb_shutdown()}.
}
\examples{
\dontshow{if (requireNamespace("adbcdrivermanager", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
library(adbcdrivermanager)
with_adbc(db <- adbc_database_init(duckdb_adbc()), {
as.data.frame(read_adbc(db, "SELECT 1 as one;"))
})
\dontshow{\}) # examplesIf}
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)
}