Description Usage Arguments Value Note Examples
Performs SQL query to extract a table from a database and can select the lines by using a condition (optional).
1 | extract_table(connection, table, selection = NULL)
|
connection |
An object that inherits from the |
table |
A string indicating which table you want to extract the data from. |
selection |
A string indicating the condition you want to use to select lines in the table (optional). |
The dataset which was the subject of the extraction, is returned as a data.table object.
It is important to leave spaces in the condition as the string is splitted on this pattern. Look at the next section for examples of valid conditions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Say for example you want to track the activities from the
## Datastorm user in the log table this is how you are going to proceed :
mydb <- DBI::dbConnect(MySQL(), user=username, password=mdp,dbname=nom_base, host=port_hote)
condition <- "userid = 46501"
log_datastorm <- extract_table_by_userid(mydb,"mdl_log",condition)
## Now you want to extract the logs
## since 01/08/2017, this is the code you must run :
condition <- "time >= '2017-08-01'"
logs2015 <- extract_table(mydb,"mdl_log",condition)
## Or you just want every log from the start of the period :
logs <- extract_table(mydb,"mdl_log")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.