ripped off the pure perl version of the postgresql driver and moved the basic structure here.

Obviously this isn't going to work so I haven't even tested it.