Connect to the taxadb database

td_connect(dbdir = taxadb_dir(), driver = Sys.getenv("TAXADB_DRIVER"))

Arguments

dbdir

Path to the database.

driver

Default driver, one of "duckdb", "MonetDBLite", "RSQLite". taxadb will select the first one of those it finds available if a driver is not set. This fallback can be overwritten either by explicit argument or by setting the environmental variable TAXADB_DRIVER.

Value

Returns a src_dbi connection to the default duckdb database

Details

This function provides a default database connection for taxadb. Note that you can use taxadb with any DBI-compatible database connection by passing the connection object directly to taxadb functions using the db argument. td_connect() exists only to provide reasonable automatic defaults based on what is available on your system.

duckdb or MonetDBLite will give the best performance, and regular users taxadb will work with the built-in RSQlite, and with other database connections such as Postgres or MariaDB, but queries (filtering joins) will be much slower on these non-columnar databases.

For performance reasons, this function will also cache and restore the existing database connection, making repeated calls to td_connect() much faster and more failsafe than repeated calls to DBI::dbConnect

Examples

# \donttest{ ## OPTIONAL: you can first set an alternative home location, ## such as a temporary directory: Sys.setenv(TAXADB_HOME=tempdir()) ## Connect to the database: db <- td_connect() # }