title: How to save data in database from shiny app?
body: <p>I want to save user'S data in the db.</p>
  <p>Every user's data should be submitted per row without any error. The data is in a function with if else condition. Every if else's output is to be saved against it's user.  How can I do it?</p>
  <p>I tried creating a dataframe for it but still the data wasn't saved in it.
  Here is reprex of my code.</p>
  <pre><code>library(shiny)
  library(tidyverse)
  ui &lt;- fluidPage(
    textInput(&quot;my_in&quot;,&quot;type a value for an entry&quot;),
    actionButton(&quot;newline_but&quot;,&quot;press for a new entry&quot;),
    tableOutput(&quot;showmytable&quot;)
  )
  
  server &lt;- function(input, output, session) {
  mydf &lt;- reactiveVal(tibble(msg=NA_character_))
    
    output$showmytable &lt;- renderTable({
      mydf()
    })
    observeEvent(input$my_in,{
      local_df &lt;- req(mydf())
      curr_row &lt;- nrow(local_df)
      local_df[curr_row,1] &lt;- input$my_in
      mydf(local_df)
    })
    observeEvent(input$newline_but,{
      local_df &lt;- req(mydf())
        
      mydf(add_row(local_df))
    })
    
    observeEvent(mydf(),
                 {
                   #export to a global but would be better to maybe write to a database
                   assign(x=&quot;exported_df&quot;,
                          value=mydf(),
                          envir = .GlobalEnv)
                 })
  }
  
  shinyApp(ui,server)```
  </code></pre>