Delete Selected row from a table when use rmysql

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Delete Selected row from a table when use rmysql

fmarzoughi
I want to delete the selected row from MySql Database when Click on delete button in my shinyapp. The codes of ui.r and server.r are as following: It is connected to MySQl and I can save data to mySQL but I cannot delete and Update the table. 1: connection to database

<nabble_embed># Define the fields we want to save from the form fields <- c("name", "used_shiny", "r_num_years") #connect to MySQL options(mysql = list( "host" = "127.0.0.1", "port" = 3306, "user" = "root", "password" = "" )) databaseName <- "myshinydatabase" table <- "responses" saveData <- function(data) { # Connect to the database db <- dbConnect(MySQL(), dbname = databaseName, host = options()$mysql$host, port = options()$mysql$port, user = options()$mysql$user, password = options()$mysql$password)</nabble_embed>
Function of delete Data :

<nabble_embed>deleteData <- function() { # Connect to the database db <- dbConnect(MySQL(), dbname = databaseName, host = options()$mysql$host, port = options()$mysql$port, user = options()$mysql$user, password = options()$mysql$password) # Construct the deleting query query <- sprintf("DELETE * FROM %s", table) # Submit the fetch query and disconnect data <- dbGetQuery(db, query) dbDisconnect(db) data }</nabble_embed>
When Delete button is clicked, delete the selected row of data
<nabble_embed>observeEvent(input$delete.button, { deleteData (formData()) })</nabble_embed>

The Error message that I get:
<nabble_embed> Listening on http://127.0.0.1:5894 Warning: Unhandled error in observer: unused argument (formData()) observeEvent(input$delete.button)</nabble_embed>