The goal of adbcflightsql is to provide a low-level developer-facing interface to the Arrow Database Connectivity (ADBC) FlightSQL driver.
Installation
You can install the released version of adbcflightsql from CRAN with:
install.packages("adbcflightsql")
You can install the development version of adbcflightsql from GitHub with:
# install.packages("pak")
pak::pak("apache/arrow-adbc/r/adbcflightsql")
ADBC drivers for R use a relatively new feature of pkgbuild to enable installation from GitHub via pak. Depending on when you installed pak, you may need to update its internal version of pkgbuild.
install.packages("pkgbuild", pak:::private_lib_dir())
pak::cache_clean()
Example
This is a basic example which shows you how to solve a common problem.
library(adbcdrivermanager)
# Use the driver manager to connect to a database. This example URI is
# grpc://localhost:8080 and uses a Go FlightSQL/SQLite server docker image
uri <- Sys.getenv("ADBC_FLIGHTSQL_TEST_URI")
db <- adbc_database_init(adbcflightsql::adbcflightsql(), uri = uri)
con <- adbc_connection_init(db)
# Write a table
con |>
execute_adbc("CREATE TABLE crossfit (exercise TEXT, difficulty_level INTEGER)") |>
execute_adbc(
"INSERT INTO crossfit values
('Push Ups', 3),
('Pull Ups', 5),
('Push Jerk', 7),
('Bar Muscle Up', 10);"
)
# Query it
con |>
read_adbc("SELECT * from crossfit") |>
tibble::as_tibble()
#> # A tibble: 4 × 2
#> exercise difficulty_level
#> <chr> <dbl>
#> 1 Push Ups 3
#> 2 Pull Ups 5
#> 3 Push Jerk 7
#> 4 Bar Muscle Up 10
# Clean up
con |>
execute_adbc("DROP TABLE crossfit")
adbc_connection_release(con)
adbc_database_release(db)