begin transaction after opening connection

in some models, the transaction may provide a consistent database to
query on, where otherwise the state could update between lines of
execution.