Original modifications for postgresql

Adapted classam/pierc, which was written to use MySQL, to instead use
PostgreSQL, because I much prefer the latter. This required modifying
the database-related code throughout the project.
Merge pull request #1 from p2j/pierc-postgres

Original modifications for postgresql