Changing the sample code to integrate with the postgres database