View source: R/tw_connect_to_cache.R
tw_connect_to_cache | R Documentation |
Return a connection to be used for caching
tw_connect_to_cache(
connection = NULL,
RSQLite = NULL,
language = tidywikidatar::tw_get_language(),
cache = NULL
)
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). |
RSQLite |
Defaults to NULL, expected either NULL or logical. If set to |
language |
Defaults to language set with |
cache |
Defaults to NULL. If given, it should be given either TRUE or FALSE. Typically set with |
A connection object.
if (interactive()) {
cache_connection <- pool::dbPool(
RSQLite::SQLite(), # or e.g. odbc::odbc(),
Driver = ":memory:", # or e.g. "MariaDB",
Host = "localhost",
database = "example_db",
UID = "example_user",
PWD = "example_pwd"
)
tw_connect_to_cache(cache_connection)
db_settings <- list(
driver = "MySQL",
host = "localhost",
server = "localhost",
port = 3306,
database = "tidywikidatar",
user = "secret_username",
pwd = "secret_password"
)
tw_connect_to_cache(db_settings)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.