Reads data from local database
Arguments
- table
Name of the table. See readme for details.
- db_connection
Defaults to NULL. If NULL, uses local SQLite database. If given, must be a connection object or a list with relevant connection settings (see example).
- disconnect_db
Defaults to TRUE. If FALSE, leaves the connection to database open.
- ...
Passed to
cas_get_db_file()
.
See also
Other database functions:
cas_check_db_folder()
,
cas_check_use_db()
,
cas_connect_to_db()
,
cas_create_db_folder()
,
cas_disable_db()
,
cas_disconnect_from_db()
,
cas_enable_db()
,
cas_get_db_settings()
,
cas_set_db()
,
cas_set_db_folder()
,
cas_write_to_db()
Examples
cas_set_options(
base_folder = fs::path(tempdir(), "R", "castarter_data"),
project = "example_project",
website = "example_website"
)
cas_enable_db()
urls_df <- cas_build_urls(
url = "https://www.example.com/news/",
start_page = 1,
end_page = 10
)
cas_write_to_db(
df = urls_df,
table = "index_id"
)
cas_read_from_db(table = "index_id")
#> # Source: table<`index_id`> [?? x 3]
#> # Database: sqlite 3.46.0 [/tmp/Rtmp1QODEK/R/castarter_data/cas_example_project_example_website_db.sqlite]
#> id url index_group
#> <dbl> <chr> <chr>
#> 1 1 https://www.example.com/news/1 index
#> 2 2 https://www.example.com/news/2 index
#> 3 3 https://www.example.com/news/3 index
#> 4 4 https://www.example.com/news/4 index
#> 5 5 https://www.example.com/news/5 index
#> 6 6 https://www.example.com/news/6 index
#> 7 7 https://www.example.com/news/7 index
#> 8 8 https://www.example.com/news/8 index
#> 9 9 https://www.example.com/news/9 index
#> 10 10 https://www.example.com/news/10 index
#> # ℹ more rows