mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
Use isolation level symbolic constants in examples
This commit is contained in:
parent
5a6a303d43
commit
424bc310a6
|
@ -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")
|
||||
|
|
|
@ -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),))
|
||||
|
|
Loading…
Reference in New Issue
Block a user