Skip to contents

Read contents from local database

Usage

cas_read_db_contents_id(db_connection = NULL, db_folder = NULL, ...)

Arguments

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).

...

Passed to cas_get_db_file().

Value

A data frame with three columns and data stored in the contents_id table of the local database. The data frame has zero rows if the database does not exist or no data was previously stored there.

Examples

cas_set_options(
  base_folder = fs::path(tempdir(), "R", "castarter_data"),
  db_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_db_contents_id(urls = urls_df$url)
#>  No new url added to contents_id table.

cas_read_db_contents_id()
#> # Source:   table<`contents_id`> [?? x 5]
#> # Database: sqlite 3.47.1 [/tmp/Rtmp7y4U5p/R/castarter_data/cas_example_project_example_website_db.sqlite]
#>       id url                        link_text source_index_id source_index_batch
#>    <dbl> <chr>                      <chr>               <dbl>              <dbl>
#>  1     1 https://www.example.com/n… NA                     NA                 NA
#>  2     2 https://www.example.com/n… NA                     NA                 NA
#>  3     3 https://www.example.com/n… NA                     NA                 NA
#>  4     4 https://www.example.com/n… NA                     NA                 NA
#>  5     5 https://www.example.com/n… NA                     NA                 NA
#>  6     6 https://www.example.com/n… NA                     NA                 NA
#>  7     7 https://www.example.com/n… NA                     NA                 NA
#>  8     8 https://www.example.com/n… NA                     NA                 NA
#>  9     9 https://www.example.com/n… NA                     NA                 NA
#> 10    10 https://www.example.com/n… NA                     NA                 NA