separating out the database selection for use in other scripts, to avoid code replication