diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-12-15 13:10:36 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-12-15 13:10:36 +0000 |
| commit | 424bc310a6a8e7189bc630a7f4509382c2c94656 (patch) | |
| tree | 1989a46dd10f2dac97ee05a57e840c18793e57f2 /examples | |
| parent | 5a6a303d43f385f885c12d87240e86d6cb421463 (diff) | |
| download | psycopg2-424bc310a6a8e7189bc630a7f4509382c2c94656.tar.gz | |
Use isolation level symbolic constants in examples
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/notify.py | 5 | ||||
| -rw-r--r-- | examples/threads.py | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/examples/notify.py b/examples/notify.py index 7dc15d2..2c2e139 100644 --- a/examples/notify.py +++ b/examples/notify.py @@ -19,8 +19,9 @@ DSN = 'dbname=test' ## don't modify anything below tis line (except for experimenting) import sys -import psycopg2 import select +import psycopg2 +from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT if len(sys.argv) > 1: DSN = sys.argv[1] @@ -29,7 +30,7 @@ print "Opening connection using dns:", DSN conn = psycopg2.connect(DSN) print "Encoding for this connection is", conn.encoding -conn.set_isolation_level(0) +conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) curs = conn.cursor() curs.execute("listen test") diff --git a/examples/threads.py b/examples/threads.py index 41ff21f..3c2ef0b 100644 --- a/examples/threads.py +++ b/examples/threads.py @@ -38,6 +38,7 @@ MODE = 1 import sys, psycopg2, threading from psycopg2.pool import ThreadedConnectionPool +from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT if len(sys.argv) > 1: DSN = sys.argv[1] @@ -96,14 +97,14 @@ def select_func(conn_or_pool, z): if MODE == 0: conn = conn_or_pool - conn.set_isolation_level(0) + conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) for i in range(SELECT_SIZE): if divmod(i, SELECT_STEP)[1] == 0: try: if MODE == 1: conn = conn_or_pool.getconn() - conn.set_isolation_level(0) + conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) c = conn.cursor() c.execute("SELECT * FROM test_threads WHERE value2 < %s", (int(i/z),)) |
