Started adding db insertion code.

Mostly copied from various PG Python tutorials online, such as:

  http://zetcode.com/db/postgresqlpythontutorial/
Minor code improvements.

Still need to improve the SQL inserts, so they're safely escaped.
Minor json server code cleanup, disable debug by default.