Prepared statements everywhere

* selectEntries method (which is a wrapper for the SELECT statement in SQL) now uses prepared statements like the rest of the database methods. To make this work, i had to make the method accept a dictionary and change the caller functions accordingly. After this gets merged, we can close #273.

* I removed numEntries method. There are a few places that this method is being used and i believe we should use selectEntries and Python's len() instead for simplicity and optimization reasons.

* Very few improvements here and there, all db-related.

Since this is not a small patch, please test it and review it thoroughly. I have tested it myself and it looks good to me.
Clamp issue.