Added pg database functionality