db.set_isolation_level(n)
का उपयोग करें, मान लें कि db
आपकी कनेक्शन ऑब्जेक्ट है। फेडरिको रूप here लिखा था, n
का अर्थ है:
0 -> autocommit
1 -> read committed
2 -> serialized (but not officially supported by pg)
3 -> serialized
रूप here प्रलेखित, psycopg2.extensions
आप इस प्रयोजन के लिए प्रतीकात्मक स्थिरांक देता है:
Setting transaction isolation levels
====================================
psycopg2 connection objects hold informations about the PostgreSQL `transaction
isolation level`_. The current transaction level can be read from the
`.isolation_level` attribute. The default isolation level is ``READ
COMMITTED``. A different isolation level con be set through the
`.set_isolation_level()` method. The level can be set to one of the following
constants, defined in `psycopg2.extensions`:
`ISOLATION_LEVEL_AUTOCOMMIT`
No transaction is started when command are issued and no
`.commit()`/`.rollback()` is required. Some PostgreSQL command such as
``CREATE DATABASE`` can't run into a transaction: to run such command use
`.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)`.
`ISOLATION_LEVEL_READ_COMMITTED`
This is the default value. A new transaction is started at the first
`.execute()` command on a cursor and at each new `.execute()` after a
`.commit()` or a `.rollback()`. The transaction runs in the PostgreSQL
``READ COMMITTED`` isolation level.
`ISOLATION_LEVEL_SERIALIZABLE`
Transactions are run at a ``SERIALIZABLE`` isolation level.
.. _transaction isolation level:
http://www.postgresql.org/docs/8.1/static/transaction-iso.html
स्रोत
2009-08-02 17:47:18
अच्छा। क्या यह autocommit करने के लिए डिफ़ॉल्ट है? एन = 1,2 या 3 सेट करते समय लेनदेन शुरू होता है? अंतिम प्रतिबद्ध/रोलबैक के बाद से नया कर्सर बनाना, या डीबी पर बस हर ऑपरेशन बनाना? – Leeeroy
ऑटोकॉमिट अधिकांश डीबीएमएस में डिफ़ॉल्ट है। –
एलेक्स ने पूछे जाने के बाद और सामान जोड़ा। और यह कहता है कि READ_COMMITED psycopg2 – Leeeroy