From 424bc310a6a8e7189bc630a7f4509382c2c94656 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 15 Dec 2011 13:10:36 +0000 Subject: [PATCH] Use isolation level symbolic constants in examples --- examples/notify.py | 5 +++-- examples/threads.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/notify.py b/examples/notify.py index 7dc15d2a..2c2e1395 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 41ff21f3..3c2ef0be 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),))