open and close connection to database for results