added some input validation for the queries and defined the funquery functions...
added some input validation for the queries and defined the funquery functions in db.py so that I could test the code I wrote. Me and mark still need to do a bit more to the query code but its almost done.