read_adbc: Read, write, and execute on ADBC connections

View source: R/helpers.R

read_adbcR Documentation

Read, write, and execute on ADBC connections

Description

These are convenience methods useful for testing connections. Note that S3 dispatch is always on db_or_con (i.e., drivers may provide their own implementations).

Usage

read_adbc(db_or_con, query, ..., bind = NULL)

execute_adbc(db_or_con, query, ..., bind = NULL)

write_adbc(
  tbl,
  db_or_con,
  target_table,
  ...,
  mode = c("default", "create", "append"),
  temporary = FALSE
)

Arguments

db_or_con

An adbc_database or adbc_connection. If a database, a connection will be opened. For read_adbc(), this connection will be closed when the resulting stream has been released.

query

An SQL query

...

Passed to S3 methods.

bind

A data.frame, nanoarrow_array, or nanoarrow_array_stream of bind parameters or NULL to skip the bind/prepare step.

tbl

A data.frame, nanoarrow_array, or nanoarrow_array_stream.

target_table

A target table name to which tbl should be written.

mode

One of "create", "append", or "default" (error if the schema is not compatible or append otherwise).

temporary

Use TRUE to create a table as a temporary table.

Value

  • read_adbc(): A nanoarrow_array_stream

  • execute_adbc(): db_or_con, invisibly.

  • write_adbc(): tbl, invisibly.

Examples

# On a database, connections are opened and closed
db <- adbc_database_init(adbc_driver_log())
try(read_adbc(db, "some sql"))
try(execute_adbc(db, "some sql"))
try(write_adbc(mtcars, db, "some_table"))

# Also works on a connection
con <- adbc_connection_init(db)
try(read_adbc(con, "some sql"))
try(execute_adbc(con, "some sql"))
try(write_adbc(mtcars, con, "some_table"))


adbcdrivermanager documentation built on Sept. 11, 2024, 5:19 p.m.