added a write database function

query_db did not have a commit and did not save what was entred in the DB

nexts steps are to modifydata structures for showing events a list does not meet all the possible states which an event can be in