Implement a withConnection
context function for ensuring connections close in scripts
#269
Labels
enhancement
New functionality that could be added
good first issue
An issue that could be solved by someone new to the package
This was discussed in the last HADES meeting and I think it would be good to implement something that we can say is our best practice principles for working with db connections to ensure they aren't left hanging. Something I'm sure everyone is guilty of in scripts at some point.
Toy example
The following is along the lines of how I think the function should look. This heavily borrows from the
withr
package style.Most OHDSI functions already use the
on.exit
to be clean but this approach is more general and could be applied everywhere.Some semantic sugar could be added around the connection details instance so you auto assign a connection with this.
A part of any PR for this should be to update any guides and examples in this package to use the agreed standard practice for ensuring the connection is closed after usage.
The text was updated successfully, but these errors were encountered: