R/datasets_to_sqlite.R
datasets_to_sql.Rd
SQL databases are the cornerstone of many data science efforts.
We provide this simple function to export all the available
datasets in available_datasets()
to any relational database
supported by dbplyr.
datasets_to_sql(
con,
dataset_accessors = available_datasets()$accessor,
overwrite = TRUE,
...
)
a remote data source. See dplyr::copy_to()
character() vector of accessors for datasets.
The accessor
column of available_datasets()
is the default, meaning
that all data.frame-like datasets will be written to the SQL destination.
If TRUE, will overwrite an existing table with name name. If FALSE, will throw an error if name already exists.
passed on to dplyr::copy_to()
used for side effects
Create connections using RSQLite::SQLite() for RSQLite, RMariaDB::MariaDB() for RMariaDB, RPostgres::Postgres() for RPostgres, odbc::odbc() for odbc, and bigrquery::bigquery() for BigQuery.
if(requireNamespace("RSQLite", quietly=TRUE)
& requireNamespace("DBI", quietly=TRUE)) {
sql = DBI::dbConnect(RSQLite::SQLite(), ':memory:')
datasets_to_sql(sql, dataset_accessors = "coronadatascraper_data")
DBI::dbListTables(sql)
DBI::dbDisconnect(sql)
} else {
print("install.packages('RSQLite') to run this example")
}
#> coronadatascraper_data
#> writing