To programmatically restart the session, you can add
session$reload()
to the error condition of a tryCatch that wraps your sql query function. However, that will just restart the app and not requery - to do that you would need to build some backend tracking of the user and store session data which is possible but possibly overkill in your case. I would suggest instead of a reload, incorporate the tryCatch with the error condition being a
shiny::showNotification()
stating to the user that there was an unexpected error and to resubmit