| --- |
| output: github_document |
| --- |
| |
| <!--- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| http://www.apache.org/licenses/LICENSE-2.0 |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| <!-- README.md is generated from README.Rmd. Please edit that file --> |
| |
| ```{r, include = FALSE} |
| knitr::opts_chunk$set( |
| collapse = TRUE, |
| comment = "#>", |
| fig.path = "man/figures/README-", |
| out.width = "100%" |
| ) |
| ``` |
| |
| # adbcpostgresql |
| |
| <!-- badges: start --> |
| <!-- badges: end --> |
| |
| The goal of adbcpostgresql is to provide a low-level developer-facing interface |
| to the Arrow Database Connectivity (ADBC) PostgreSQL driver. |
| |
| ## Installation |
| |
| You can install the released version of adbcpostgresql from [CRAN](https://cran.r-project.org/) with: |
| |
| ```r |
| install.packages("adbcpostgresql") |
| ``` |
| |
| You can install the development version of adbcpostgresql from [GitHub](https://github.com/) with: |
| |
| ``` r |
| # install.packages("pak") |
| pak::pak("apache/arrow-adbc/r/adbcpostgresql") |
| ``` |
| |
| 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. |
| |
| ``` r |
| 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: |
| |
| ```{r example} |
| library(adbcdrivermanager) |
| |
| # Use the driver manager to connect to a database |
| uri <- Sys.getenv("ADBC_POSTGRESQL_TEST_URI") |
| db <- adbc_database_init(adbcpostgresql::adbcpostgresql(), uri = uri) |
| con <- adbc_connection_init(db) |
| |
| # Write a table |
| flights <- head(nycflights13::flights, 100) |
| # (timestamp not supported yet) |
| flights$time_hour <- NULL |
| flights |> |
| write_adbc(con, "flights") |
| |
| # Query it |
| con |> |
| read_adbc("SELECT * from flights") |> |
| tibble::as_tibble() |
| ``` |
| |
| ```{r example-clean-up} |
| # Clean up |
| con |> |
| execute_adbc("DROP TABLE flights") |
| adbc_connection_release(con) |
| adbc_database_release(db) |
| ``` |