Description Usage Arguments See Also Examples
Read from, write to, and check data from the MySQL databases and tables in the Wikimedia cluster. Assumes the presence of a validly formatted configuration file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | mysql_connect(
database,
use_x1 = FALSE,
default_file = NULL,
hostname = NULL,
port = NULL
)
mysql_read(query, database = NULL, use_x1 = NULL, con = NULL)
mysql_exists(database, table_name, use_x1 = NULL, con = NULL)
mysql_write(x, database, table_name, use_x1 = NULL, con = NULL, ...)
mysql_close(con)
mysql_disconnect(con)
|
database |
name of the database to query; optional if passing a |
use_x1 |
logical flag; use if querying an extension-related table that
is hosted on x1 (e.g. |
default_file |
name of a config file containing username and password to use when connecting |
hostname |
name of the machine to connect to, which depends on whether
|
query |
SQL query |
con |
MySQL connection returned by |
table_name |
name of a table to check for the existence of or create, depending on the function |
x |
a |
... |
additional arguments to pass to |
query_hive()
or global_query()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
# Connection details (which shard to connect to) are fetched automatically:
mysql_read("SELECT * FROM image LIMIT 100", "commonswiki")
mysql_read("SELECT * FROM wbc_entity_usage LIMIT 100", "wikidatawiki")
# Echo extension tables are on the x1 host:
mysql_read("SELECT *
FROM echo_event
LEFT JOIN echo_notification
ON echo_event.event_id = echo_notification.notification_event
LIMIT 10;",
"enwiki", use_x1 = TRUE)
# If querying multiple databases in the same shard
# a shared connection may be used:
con <- mysql_connect("frwiki")
results <- purrr::map(
c("frwiki", "jawiki"),
mysql_read,
query = "SELECT...",
con = con
)
mysql_disconnect(con)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.