Ejemplo n.º 1
0
 def setUp(self):
     self.conn = psycoev.connect(tests.dsn)
     self.curs = self.conn.cursor()
     self.DATE = psycoev._psycopg.PYDATE
     self.TIME = psycoev._psycopg.PYTIME
     self.DATETIME = psycoev._psycopg.PYDATETIME
     self.INTERVAL = psycoev._psycopg.PYINTERVAL
Ejemplo n.º 2
0
Archivo: pool.py Proyecto: fabioz/coev
 def _connect(self, key=None):
     """Create a new connection and assign it to 'key' if not None."""
     conn = psycoev.connect(*self._args, **self._kwargs)
     if key is not None:
         self._used[key] = conn
         self._rused[id(conn)] = key
     else:
         self._pool.append(conn)
     return conn
Ejemplo n.º 3
0
 def setUp(self):
     self.conn = psycoev.connect(tests.dsn)
     self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
     curs = self.conn.cursor()
     curs.execute('''
         CREATE TEMPORARY TABLE table1 (
           id int PRIMARY KEY
         )''')
     # The constraint is set to deferrable for the commit_failed test
     curs.execute('''
         CREATE TEMPORARY TABLE table2 (
           id int PRIMARY KEY,
           table1_id int,
           CONSTRAINT table2__table1_id__fk
             FOREIGN KEY (table1_id) REFERENCES table1(id) DEFERRABLE)''')
     curs.execute('INSERT INTO table1 VALUES (1)')
     curs.execute('INSERT INTO table2 VALUES (1, 1)')
     self.conn.commit()
Ejemplo n.º 4
0
DSN = 'dbname=test'

## don't modify anything below this line (except for experimenting)

class SimpleQuoter(object):
    def sqlquote(x=None):
        return "'bar'"

import sys
import psycoev

if len(sys.argv) > 1:
    DSN = sys.argv[1]

print "Opening connection using dns:", DSN
conn = psycoev.connect(DSN)
print "Encoding for this connection is", conn.encoding

curs = conn.cursor()
curs.execute("SELECT 1 AS foo")
print curs.fetchone()
curs.execute("SELECT 1 AS foo")
print curs.fetchmany()
curs.execute("SELECT 1 AS foo")
print curs.fetchall()

conn.rollback()

sys.exit(0)

curs.execute("SELECT 1 AS foo", async=1)
Ejemplo n.º 5
0
 def setUp(self):
     self.conn = psycoev.connect(tests.dsn)
     self.lo_oid = None
     self.tmpdir = None
Ejemplo n.º 6
0
# 1 - connections generated using the connection pool

MODE = 1

## don't modify anything below tis line (except for experimenting)

import sys, psycoev, threading
from psycoev.pool import ThreadedConnectionPool

if len(sys.argv) > 1:
    DSN = sys.argv[1]
if len(sys.argv) > 2:
    MODE = int(sys.argv[2])
    
print "Opening connection using dns:", DSN
conn = psycoev.connect(DSN)
curs = conn.cursor()

try:
    curs.execute("""CREATE TABLE test_threads (
                        name text, value1 int4, value2 float)""")
except:
    conn.rollback()
    curs.execute("DROP TABLE test_threads")
    curs.execute("""CREATE TABLE test_threads (
                        name text, value1 int4, value2 float)""")
conn.commit()


## this function inserts a big number of rows and creates and destroys
## a large number of cursors
Ejemplo n.º 7
0
 def setUp(self):
     self.conn = psycoev.connect(tests.dsn)
Ejemplo n.º 8
0
 def connect(self):
     conn = psycoev.connect(tests.dsn)
     conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
     return conn
Ejemplo n.º 9
0
 def setUp(self):
     self.conn = psycoev.connect(tests.dsn)
     self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
Ejemplo n.º 10
0
 def connect(self):
     return psycoev.connect(tests.dsn)
Ejemplo n.º 11
0
 def setUp(self):
     self.conn = psycoev.connect(tests.dsn)
     curs = self.conn.cursor()
     curs.execute("CREATE TEMPORARY TABLE ExtrasDictCursorTests (foo text)")