Tested only with SQLite and MySql. May work with other drivers.
tw_index_cache_item(
table_name = NULL,
check_first = TRUE,
type = "item",
show_details = FALSE,
language = tidywikidatar::tw_get_language(),
cache = NULL,
cache_connection = NULL,
disconnect_db = TRUE
)
If show_details
is set to FALSE, nothing, used only for its side effects (add index to caching table). If TRUE, a data frame, same as the output of tw_check_cache_index(show_details = TRUE)
.
Name of the table in the database. If given, it takes precedence over other parameters.
Logical, defaults to TRUE
. If TRUE
, then before executing anything on the database it checks if the given table has already been indexed. If it has, it does nothing and returns only an informative message.
Defaults to "item". Type of cache file to output. Values typically used by tidywikidatar
include "item", "search_item", "search_property", and "qualifier".
Logical, defaults to FALSE
. If FALSE
, return the function adds the index to the database, but does not return anything. If TRUE
, returns a data frame with more details about the index.
Defaults to language set with tw_set_language()
; "en" if not set. Used to limit the data to be cached. Use "all_available" to keep all data. For available values, see https://www.wikidata.org/wiki/Help:Wikimedia_language_codes/lists/all
Defaults to NULL. If given, it should be given either TRUE or FALSE. Typically set with tw_enable_cache()
or tw_disable_cache()
.
Defaults to NULL. If NULL, and caching is enabled, tidywikidatar
will use a local sqlite database. A custom connection to other databases can be given (see vignette caching
for details).
Defaults to TRUE. If FALSE, leaves the connection to cache open.
To ensure smooth functioning, the search column in the cache table is transformed into a column of type varchar
and length 255.
if (interactive()) {
tw_enable_cache()
tw_set_cache_folder(path = fs::path(
fs::path_home_r(),
"R",
"tw_data"
))
tw_index_cache_search()
}
Run the code above in your browser using DataLab