| starwars_db | R Documentation | 
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().
starwars_connect(dbdir = ":memory:", ...)
starwars_disconnect(con)
starwars_db()
dbdir | 
 Location for database files. Should be a path to an existing
directory in the file system. With the default (or   | 
... | 
 Additional parameters passed to   | 
con | 
 A connection to the Star Wars database  | 
A connection to the Star Wars database, or the path to the database.
starwars_connect(): Connect to the DuckDB database
starwars_disconnect(): Disconnect from the DuckDB database
starwars_db(): Returns the path to the starwarsdb database
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.