how to fetch data from postgresql database