Code migration

Moved random chunks of code into an opendb() function so that they don't
execute upon importing the dataConnectionFunctions file