Add support for Postgresql.

Add support for connecting to Postgresql. Modify SQL statements to be compatible with Postgresql. Refs trustmaster/trac2github#9