Error while saving data in databse from R shiny

Hello all,

I am getting an err- "Warning: Error in : MySQL server has gone away [2006]" or while saving data into a database-

My reprex-

library(shiny)
library(tidyverse)

iapply = pool::dbPool(drv = RMariaDB::MariaDB(), dbname = "dbname",
                   host = "11.111.111.11", port=3306,
                   user = "user",  password = "password")

save<- pool::dbPool(drv = RMariaDB::MariaDB(), dbname = "dbname1",
                   host = "11.111.111.12", port=3306,
                   user = "user1",  password = "password1")


ui <- fluidPage(
  textInput("my_in","type a value for an entry"),
  actionButton("newline_but","press for a new entry"),
  tableOutput("showmytable")
)

server <- function(input, output, session) {
mydf <- reactiveVal(tibble(msg=NA_character_))
  
  output$showmytable <- renderTable({
    mydf()
  })
  observeEvent(input$my_in,{
    local_df <- req(mydf())
    curr_row <- nrow(local_df)
    local_df[curr_row,1] <- input$my_in
    mydf(local_df)
  })
  observeEvent(input$newline_but,{
    local_df <- 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="new_file",
                        value=mydf(),
                        envir = .GlobalEnv)
               })
iapply = pool::dbPool(drv = RMariaDB::MariaDB(), dbname = "dbname1",
                   host = "xx.xxxx.xx.xx", port=3306,
                   user = "user1",  password = "password1")
observe({
    if(mydf()!=")
    {
      dbWriteTable(save, value=new_file, name='dbname1', append=TRUE, row.names=FALSE ,
                   overwrite=FALSE)
    }
    
  })
}

shinyApp(ui, server)

I notice that you assign iapply twice, but dont appear to use it at all ?
dbWriteTable first param should be the connection, you refer to it as 'save' , where is the definition for that ?

Usage
dbWriteTable(conn, name, value, ...)
Arguments
conn
A DBIConnection object, as returned by dbConnect().

name
A character string specifying the unquoted DBMS table name, or the result of a call to dbQuoteIdentifier().

value
a data.frame (or coercible to data.frame).

...
Other parameters passed on to methods.

Hi Nik, I forgot to add here but in the main program, I had added the 'save' connection name.
I have updated the same here.