database connection moved

moved database connection into separate config and function files.