Learn R Programming

adbcdrivermanager (version 0.22.0)

read_adbc: 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", "replace", "create_append"), temporary = FALSE, catalog_name = NULL, db_schema_name = NULL )

Value

  • read_adbc(): A nanoarrow_array_stream

  • execute_adbc(): db_or_con, invisibly.

  • write_adbc(): tbl, invisibly.

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", "replace", "create_append" (error if the schema is not compatible or append otherwise), or "default" (use the adbc.ingest.mode argument of adbc_statement_init()). The default is "default".

temporary

Use TRUE to create a table as a temporary table.

catalog_name

If not NULL, the catalog to create/locate the table in.

db_schema_name

If not NULL, the schema to create/locate the table in.

Examples

Run this code
# 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"))

Run the code above in your browser using DataLab