I have an R Plumber API and it's purpose is to receive webhook data, sanitise the data, and then pass it on to a relational database.
Is it considered best practice for the API to maintain a constant state of connection to the DB (something like con <- DBI::dbConnect(...)
) and just never closing the connection, or is it instead best practice to open and close the connection between the Plumber API and the DB each time data is sent?
I realise this is somewhat subjective, but I do urge any potential 'closers' to be mindful of how helpful this discussion can be for a developer who is not a database expert. Thank you in advance.