added a db connection helper

cleaned up the db querying. also forgot to add show_event template in
the previous commit