1 | initial version |
R Shiny can be utilized to generate buttons that execute mysql code by utilizing the RMySQL package. Below is an example code snippet that shows how this can be done:
install.packages("RMySQL")
library(RMySQL)
con <- dbConnect(MySQL(),user='username',password='password',dbname='database_name',host='host_name')
Replace username, password, databasename and hostname with the relevant credentials.
query <- "SELECT * FROM table_name"
Replace table_name with the name of your table.
actionButton("execute_query", "Execute Query")
observeEvent(input$execute_query,{
data <- dbGetQuery(con,query)
#Do something with the data returned by the query
})
onStop(dbDisconnect(con))
These steps can be repeated with different queries and buttons to execute several mysql commands via R Shiny.