DuckDB connection class
Source:R/Connection.R, R/dbAppendTable__duckdb_connection.R, R/dbBegin__duckdb_connection.R, and 16 more
duckdb_connection-class.RdImplements DBIConnection.
Usage
# S4 method for class 'duckdb_connection'
dbAppendTable(conn, name, value, ..., row.names = NULL)
# S4 method for class 'duckdb_connection'
dbBegin(conn, ...)
# S4 method for class 'duckdb_connection'
dbCommit(conn, ...)
# S4 method for class 'duckdb_connection'
dbDataType(dbObj, obj, ...)
# S4 method for class 'duckdb_connection,ANY'
dbExistsTable(conn, name, ...)
# S4 method for class 'duckdb_connection'
dbGetInfo(dbObj, ...)
# S4 method for class 'duckdb_connection'
dbIsValid(dbObj, ...)
# S4 method for class 'duckdb_connection,Id'
dbListFields(conn, name, ...)
# S4 method for class 'duckdb_connection,character'
dbListFields(conn, name, ...)
# S4 method for class 'duckdb_connection'
dbListTables(conn, ...)
# S4 method for class 'duckdb_connection,ANY'
dbQuoteIdentifier(conn, x, ...)
# S4 method for class 'duckdb_connection'
dbQuoteLiteral(conn, x, ...)
# S4 method for class 'duckdb_connection,character'
dbRemoveTable(conn, name, ..., fail_if_missing = TRUE)
# S4 method for class 'duckdb_connection'
dbRollback(conn, ...)
# S4 method for class 'duckdb_connection,character'
dbSendQueryArrow(conn, statement, params = NULL, ...)
# S4 method for class 'duckdb_connection,character'
dbSendQuery(conn, statement, params = NULL, ..., arrow = FALSE)
# S4 method for class 'duckdb_connection,character,data.frame'
dbWriteTable(
conn,
name,
value,
...,
row.names = FALSE,
overwrite = FALSE,
append = FALSE,
field.types = NULL,
temporary = FALSE
)
# S4 method for class 'duckdb_connection'
show(object)Arguments
- conn
A duckdb_connection object as returned by
DBI::dbConnect()- name
The table name, passed on to
dbQuoteIdentifier(). Options are:a character string with the unquoted DBMS table name, e.g.
"table_name",a call to
Id()with components to the fully qualified table name, e.g.Id(schema = "my_schema", table = "table_name")a call to
SQL()with the quoted and fully qualified table name given verbatim, e.g.SQL('"my_schema"."table_name"')
- value
A data.frame (or coercible to data.frame).
- ...
Other parameters passed on to methods.
- row.names
Whether the row.names of the data.frame should be preserved
- dbObj
An object inheriting from class duckdb_connection.
- obj
An R object whose SQL type we want to determine.
- statement
a character string containing SQL.
- params
For
dbBind(), a list of values, named or unnamed, or a data frame, with one element/column per query parameter. FordbBindArrow(), values as a nanoarrow stream, with one column per query parameter.- arrow
Whether the query should be returned as an Arrow Table
- overwrite
If a table with the given name already exists, should it be overwritten?
- append
If a table with the given name already exists, just try to append the passed data to it
- field.types
Override the auto-generated SQL types
- temporary
Should the created table be temporary?
- object
Any R object
Slots
conn_refexternal pointer to the underlying DuckDB connection.
driverthe duckdb_driver this connection was opened from.
debugwhether debug information (such as queries) is printed.
convert_optsinternal options controlling how result values are converted to R.
reserved_wordscharacter vector of the engine's reserved SQL keywords, used to quote identifiers.
timezone_outtime zone results are returned in; superseded by
convert_opts, from which it is copied at construction, and no longer read internally.tz_out_converthow timestamps are converted to
timezone_out("with"or"force"); superseded byconvert_opts.biginthow 64-bit integers are returned; superseded by
convert_opts.
Multiple statements
A statement can hold several SQL statements separated by semicolons,
in dbSendQuery(), dbSendQueryArrow(),
and the helpers built on them, such as dbExecute() and dbGetQuery().
They run in order, and each is prepared only after those before it have run,
so it sees their effects:
a PRAGMA that generates SQL, such as create_fts_index,
finds a table created earlier in the same string.
Every statement but the last runs when the query is sent,
params bind to the last statement only,
and only the last statement's result is returned.
The whole string is parsed before anything runs,
so a syntax error in any statement means that none of them run.
Any other error stops at the statement that raised it,
and the statements before it keep their effect,
because the string does not run in a transaction of its own.
For all or nothing, run the call inside dbWithTransaction(),
or call dbBegin() before it and dbRollback() if it fails.
To know which statements have run when one fails,
send one statement per call.