Change database backend from SQLite to PostgreSQL.

This migration was prompted by experiencing significant concurrency and
disk image corruption problems with SQLite, even with WAL enabled.
Results could not be written and often could not be read.

Differences in query parameter substitution require wide-ranging
cosmetic changes. Similarly .execute() returns None instead of a cursor,
so any .fetch*() must be performed separately.

Timestamps are stored as TIMESTAMP WITH TIME ZONE instead of integers
that happen to be POSIX timestamps. This is nice in that the column
type is now semantically meaningful. Similarly duration is now an
INTERVAL. These changes allow moving timestamp and timedelta handling
to the database layer. Therefore custom handling functions are removed.
(Equivalent functions were part of DB-API 2.0 this entire time, too.
Whoops.)

There are now explicit id columns, replacing the implicit ROWID from
SQLite. From the PostgreSQL documentation: "Relational database theory
dictates that every table must have a primary key. This rule is not
enforced by PostgreSQL, but it is usually best to follow it."

All ids are SERIAL instead of BIGSERIAL [0] except link_lengths. This is
because while the other tables have ~80 years or more before running
out of index values, link_lengths would have closer to 13 years.

There are standalone tools for database operations:

    * update_db.py: Create a database and assign privileges.
    * copy_from.py: Import PostgreSQL dumps.
    * copy_to.py: Export PostgreSQL dumps.
    * migrate_from_sqlite.py: Import SQLite data into PostgreSQL.

reject_stats entries were previously missing duration.

PostgreSQL extensions used are:
    * INSERT RETURN in probe.py peer_count insert.
    * COPY TO and COPY FROM in copy_to.py and copy_from.py.
    * SERIAL, BIGSERIAL, pg_get_serial_sequence() for id columns.

There is no index on link_lengths(count_id), which makes queries involving
a JOIN to peer_count slow, but current versions of the PostgreSQL query
planner (9.2, 9.3-beta2) have cost estimation problems and do not use it.

[0] http://www.postgresql.org/docs/current/static/datatype-numeric.html
Remove outdated util script.

It wasn't really useful anymore and still uses sqlite3-specific stuff.
Remove stale PID file on stop too.
Print waiting message during stop every 5 seconds.

Unlike printing at a rate dependent on how quickly the variable
increments this is more consistent, less surprising, and less likely to
print an excessive number of lines.