Consolidate database connection logic
This MR hides the long and repetitive db connection opening logic that's used in several commands. While this code is mostly declarative and easy to understand, it takes up a significant number of lines and could distract from the code around it.
Edited by Hayley Swimelar