Added connection establishment with postgresql db, changed sql statements