Add reconnection support.

Renamed pg to make a bigger distinction between postgresql
(the connector), pg (the connection library), and the individual
connection.