cites_db: The local CITES database

View source: R/connect.R

cites_dbR Documentation

The local CITES database

Description

Returns a connection to the local CITES database. This is a DBI-compliant duckdb::duckdb() database connection. When using dplyr-based workflows, one typically accesses tables with functions such as cites_shipments(), but this function lets one interact with the database directly via SQL.

Usage

cites_db(dbdir = cites_path())

Arguments

dbdir

The location of the database on disk. Defaults to citesdb under rappdirs::user_data_dir(), or the environment variable CITES_DB_DIR.

Value

A DuckDB DBI connection

Examples

if (cites_status()) {
  library(DBI)

  dbListTables(cites_db())

  parties <- dbReadTable(cites_db(), "cites_parties")

  dbGetQuery(
   cites_db(),
   'SELECT "Taxon", "Importer" FROM cites_shipments WHERE "Year" = 1976 LIMIT 100;'
   )
}

ropensci/citesdb documentation built on May 13, 2023, 1:53 a.m.