starwars_db: Connect to the Star Wars Database

Description Usage Arguments Value Functions Examples

View source: R/connect.R

Description

Provides a connection to a DuckDB database of the Star Wars data. Alternatively, you can use starwars_db() to manually connect to the database using DBI::dbConnect() and duckdb::duckdb().

Usage

1
2
3
4
5

Arguments

dbdir

Location for database files. Should be a path to an existing directory in the file system. With the default, all data is kept in RAM

...

Additional parameters passed to DBI::dbConnect()

con

A connection to the Star Wars database

Value

A connection to the Star Wars database, or the path to the database.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Manually connect using {duckdb} and {DBI}
con <- DBI::dbConnect(
  duckdb::duckdb(),
  dbdir = starwars_db(),
  read_only = TRUE
)

if (requireNamespace("dplyr", quietly = TRUE)) {
  dplyr::tbl(con, "films")
}

# Disconnect from that database (shutdown is specific to duckdb)
DBI::dbDisconnect(con, shutdown = TRUE)

# Or connect without worrying about connection details
con <- starwars_connect()

if (requireNamespace("dplyr", quietly = TRUE)) {
  dplyr::tbl(con, "films")
}

# Similarly, disconnect quickly without worrying about duckdb arguments
starwars_disconnect(con)

starwarsdb documentation built on Nov. 8, 2020, 4:41 p.m.