擅长:python、mysql、java
<p>隔离级别是在事务中设置的,例如</p>
<pre><code>try:
Session.begin()
Session.execute('set transaction isolation level serializable')
self.find_or_create(kwarg1=value1)
except:
...
</code></pre>
<p>来自<a href="http://www.postgresql.org/docs/current/static/sql-set-transaction.html" rel="nofollow noreferrer">PostgreSQL doc</a>:</p>
<blockquote>
<p>If SET TRANSACTION is executed without a prior START TRANSACTION or BEGIN, it will appear to have no effect, since the transaction will immediately end.</p>
</blockquote>