RetryOperationalError should raise peewee.OperationalError
What will happen, if there are several statements in one transaction, and in the middle of execution, an operation error is raised?
 > What will happen, if there are several statements in one transaction, and in the middle of execution, an operation error is raised?

You can read the code to find out!

Its actually a bit complex so I'll try to explain. If you are not in a transaction, have autocommit enabled (on by default), and autorollback enabled (**off** by default), then the txn will be rolled back and the exception raised for your application to handle.

When you enter a transaction, peewee tells the database to disable autocommit, so the automatic rollback will not happen in `execute_sql()`. If an unhandled exception does bubble up to the `transaction` object, though, it will rollback before raising the exception to your code.

So if you're using the `RetryOperationalError`mixin, the first `OperationalError` is caught before it bubbles up to the txn so nothing happens. If the retry fails, though, you will get a rollback and an exception.
 should have commit or rollback before to raise exception?

``` python
  def execute_sql(self, sql, params=None, require_commit=True):
        try:
            cursor = super(RetryOperationalError, self).execute_sql(
                sql, params, require_commit)
        except OperationalError:
            if not self.is_closed():
                self.close()
            with self.exception_wrapper():
                cursor = self.get_cursor()
                try:
                    cursor.execute(sql, params or ())
                except Exception:
                    if self.get_autocommit() and self.autorollback:
                        self.rollback()
                    raise
                else:
                    if require_commit and self.get_autocommit():
                        self.commit()
        return cursor
```
 @mathisonqin -- I'm sorry but I'm not following your comment. Do you mind clarifying?

With current RetryOperationalError implementation, for mysql, a second operation error will cause _mysql_exceptions.OperationalError being re-raised. I'd expect peewee.OperationalError in this case.

``` python
class RetryOperationalError(object):
    def execute_sql(self, sql, params=None, require_commit=True):
        try:
            cursor = super(RetryOperationalError, self).execute_sql(
                sql, params, require_commit)
        except OperationalError:
            if not self.is_closed():
                self.close()
            cursor = self.get_cursor()
            cursor.execute(sql, params or ())
            if require_commit and self.get_autocommit():
                self.commit()
        return cursor
```
