changed mysql connection to automatically unlock tables at the end of a transaction