Added most of the database connection and quering implementation.