Connection and query over postgresql