Speed up driver

Re-arrange the code as a state machine to give > 30% speedup.
Add facility for turning auto-commit on

This follows the suggestion of funkybob to fix the problem of not being
able to execute a command such as 'create database' that must be
executed outside a transaction. Now you can do conn.autocommit = True
and then execute 'create database'. Test case added.
Merge pull request #16 from tlocke/py3

Speed up driver