@
sun1991 赞同老哥的说法, 不能用 MySQL 的理论去套 oracle, 开启事务的时候设定隔离级别为 serialize 不失为解决 不可重复读, 幻读的好方法.
其实 MySQL 官方的 Python Connector 库开启事务的时候, 就有指定隔离级别的参数, 只是我们几乎都习惯了固定为 REPEATABLE READ.
```python
def start_transaction(self, consistent_snapshot=False,
isolation_level=None, readonly=None):
"""Start a transaction
This method explicitly starts a transaction sending the
START TRANSACTION statement to the MySQL server. You can optionally
set whether there should be a consistent snapshot, which
isolation level you need or which access mode i.e. READ ONLY or
READ WRITE.
For example, to start a transaction with isolation level SERIALIZABLE,
you would do the following:
>>> cnx = mysql.connector.connect(..)
>>> cnx.start_transaction(isolation_level='SERIALIZABLE')
Raises ProgrammingError when a transaction is already in progress
and when ValueError when isolation_level specifies an Unknown
level.
"""
```