Working example of accessing the DB with threading