Example #1
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.curs = self.conn.cursor()
     self.DATE = psycopg2.extensions.PYDATE
     self.TIME = psycopg2.extensions.PYTIME
     self.DATETIME = psycopg2.extensions.PYDATETIME
     self.INTERVAL = psycopg2.extensions.PYINTERVAL
Example #2
0
    def tearDown(self):
        curs = self.conn.cursor()
        curs.execute("DROP TABLE table1")
        curs.execute("DROP TABLE table2")
        self.conn.commit()

        ConnectingTestCase.tearDown(self)
    def tearDown(self):
        curs = self.conn.cursor()
        curs.execute("DROP TABLE table1")
        curs.execute("DROP TABLE table2")
        self.conn.commit()

        ConnectingTestCase.tearDown(self)
Example #4
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.curs = self.conn.cursor()
     self.DATE = psycopg2.extensions.PYDATE
     self.TIME = psycopg2.extensions.PYTIME
     self.DATETIME = psycopg2.extensions.PYDATETIME
     self.INTERVAL = psycopg2.extensions.PYINTERVAL
Example #5
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        cur = self.conn.cursor()
        cur.execute('''
            CREATE TEMPORARY TABLE table1 (
              id int PRIMARY KEY
            )''')
        self.conn.commit()
    def setUp(self):
        ConnectingTestCase.setUp(self)

        cur = self.conn.cursor()
        cur.execute('''
            CREATE TEMPORARY TABLE table1 (
              id int PRIMARY KEY
            )''')
        self.conn.commit()
Example #7
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     curs = self.conn.cursor()
     try:
         curs.execute("delete from test_with")
         self.conn.commit()
     except psycopg2.ProgrammingError:
         # assume table doesn't exist
         self.conn.rollback()
         curs.execute("create table test_with (id integer primary key)")
         self.conn.commit()
Example #8
0
    def setUp(self):
        ConnectingTestCase.setUp(self)
        from psycopg2.extras import NamedTupleConnection

        self.conn = self.connect(connection_factory=NamedTupleConnection)
        curs = self.conn.cursor()
        curs.execute("CREATE TEMPORARY TABLE nttest (i int, s text)")
        curs.execute("INSERT INTO nttest VALUES (1, 'foo')")
        curs.execute("INSERT INTO nttest VALUES (2, 'bar')")
        curs.execute("INSERT INTO nttest VALUES (3, 'baz')")
        self.conn.commit()
 def setUp(self):
     ConnectingTestCase.setUp(self)
     curs = self.conn.cursor()
     try:
         curs.execute("delete from test_with")
         self.conn.commit()
     except psycopg2.ProgrammingError:
         # assume table doesn't exist
         self.conn.rollback()
         curs.execute("create table test_with (id integer primary key)")
         self.conn.commit()
Example #10
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        conn = self.connect()
        cur = conn.cursor()
        try:
            cur.execute("drop table isolevel;")
        except psycopg2.ProgrammingError:
            conn.rollback()
        cur.execute("create table isolevel (id integer);")
        conn.commit()
        conn.close()
Example #11
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        self.sync_conn = self.conn
        self.conn = self.connect(async=True)

        self.wait(self.conn)

        curs = self.conn.cursor()
        curs.execute('''
            CREATE TEMPORARY TABLE table1 (
              id int PRIMARY KEY
            )''')
        self.wait(curs)
Example #12
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        self.sync_conn = self.conn
        self.conn = self.connect(async=True)

        self.wait(self.conn)

        curs = self.conn.cursor()
        curs.execute('''
            CREATE TEMPORARY TABLE table1 (
              id int PRIMARY KEY
            )''')
        self.wait(curs)
Example #13
0
    def setUp(self):
        ConnectingTestCase.setUp(self)
        self.curs = self.conn.cursor()
        self.DATE = psycopg2._psycopg.MXDATE
        self.TIME = psycopg2._psycopg.MXTIME
        self.DATETIME = psycopg2._psycopg.MXDATETIME
        self.INTERVAL = psycopg2._psycopg.MXINTERVAL

        psycopg2.extensions.register_type(self.DATE, self.conn)
        psycopg2.extensions.register_type(self.TIME, self.conn)
        psycopg2.extensions.register_type(self.DATETIME, self.conn)
        psycopg2.extensions.register_type(self.INTERVAL, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXDATEARRAY, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXTIMEARRAY, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXDATETIMEARRAY, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXINTERVALARRAY, self.conn)
    def setUp(self):
        ConnectingTestCase.setUp(self)
        from psycopg2.extras import NamedTupleConnection

        try:
            from collections import namedtuple
        except ImportError:
            return

        self.conn = self.connect(connection_factory=NamedTupleConnection)
        curs = self.conn.cursor()
        curs.execute("CREATE TEMPORARY TABLE nttest (i int, s text)")
        curs.execute("INSERT INTO nttest VALUES (1, 'foo')")
        curs.execute("INSERT INTO nttest VALUES (2, 'bar')")
        curs.execute("INSERT INTO nttest VALUES (3, 'baz')")
        self.conn.commit()
Example #15
0
    def setUp(self):
        ConnectingTestCase.setUp(self)
        self.curs = self.conn.cursor()
        self.DATE = psycopg2._psycopg.MXDATE
        self.TIME = psycopg2._psycopg.MXTIME
        self.DATETIME = psycopg2._psycopg.MXDATETIME
        self.INTERVAL = psycopg2._psycopg.MXINTERVAL

        psycopg2.extensions.register_type(self.DATE, self.conn)
        psycopg2.extensions.register_type(self.TIME, self.conn)
        psycopg2.extensions.register_type(self.DATETIME, self.conn)
        psycopg2.extensions.register_type(self.INTERVAL, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXDATEARRAY, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXTIMEARRAY, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXDATETIMEARRAY, self.conn)
        psycopg2.extensions.register_type(psycopg2.extensions.MXINTERVALARRAY, self.conn)
Example #16
0
    def tearDown(self):
        if self.tmpdir:
            shutil.rmtree(self.tmpdir, ignore_errors=True)

        if self.conn.closed:
            return

        if self.lo_oid is not None:
            self.conn.rollback()
            try:
                lo = self.conn.lobject(self.lo_oid, "n")
            except psycopg2.OperationalError:
                pass
            else:
                lo.unlink()

        ConnectingTestCase.tearDown(self)
    def tearDown(self):
        if self.tmpdir:
            shutil.rmtree(self.tmpdir, ignore_errors=True)

        if self.conn.closed:
            return

        if self.lo_oid is not None:
            self.conn.rollback()
            try:
                lo = self.conn.lobject(self.lo_oid, "n")
            except psycopg2.OperationalError:
                pass
            else:
                lo.unlink()

        ConnectingTestCase.tearDown(self)
 def setUp(self):
     ConnectingTestCase.setUp(self)
     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()
Example #19
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     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()
Example #20
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        curs = self.conn.cursor()
        # Drop table if it already exists
        try:
            curs.execute("DROP TABLE table1")
            self.conn.commit()
        except psycopg2.DatabaseError:
            self.conn.rollback()
        try:
            curs.execute("DROP TABLE table2")
            self.conn.commit()
        except psycopg2.DatabaseError:
            self.conn.rollback()
        # Create sample data
        curs.execute("""
            CREATE TABLE table1 (
                id int PRIMARY KEY,
                name text)
        """)
        curs.execute("INSERT INTO table1 VALUES (1, 'hello')")
        curs.execute("CREATE TABLE table2 (id int PRIMARY KEY)")
        self.conn.commit()
    def setUp(self):
        ConnectingTestCase.setUp(self)

        curs = self.conn.cursor()
        # Drop table if it already exists
        try:
            curs.execute("DROP TABLE table1")
            self.conn.commit()
        except psycopg2.DatabaseError:
            self.conn.rollback()
        try:
            curs.execute("DROP TABLE table2")
            self.conn.commit()
        except psycopg2.DatabaseError:
            self.conn.rollback()
        # Create sample data
        curs.execute("""
            CREATE TABLE table1 (
                id int PRIMARY KEY,
                name text)
        """)
        curs.execute("INSERT INTO table1 VALUES (1, 'hello')")
        curs.execute("CREATE TABLE table2 (id int PRIMARY KEY)")
        self.conn.commit()
 def setUp(self):
     ConnectingTestCase.setUp(self)
     curs = self.conn.cursor()
     curs.execute("CREATE TEMPORARY TABLE ExtrasDictCursorTests (foo text)")
     curs.execute("INSERT INTO ExtrasDictCursorTests VALUES ('bar')")
     self.conn.commit()
 def connect(self):
     conn = ConnectingTestCase.connect(self)
     conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
     return conn
Example #24
0
 def setUp(self):
     self._cb = psycopg2.extensions.get_wait_callback()
     psycopg2.extensions.set_wait_callback(psycopg2.extras.wait_select)
     ConnectingTestCase.setUp(self)
Example #25
0
 def connect(self):
     conn = ConnectingTestCase.connect(self)
     conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
     return conn
Example #26
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
Example #27
0
 def tearDown(self):
     ConnectingTestCase.tearDown(self)
     psycopg2.extensions.set_wait_callback(self._cb)
Example #28
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.lo_oid = None
     self.tmpdir = None
Example #29
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self._create_temp_table()
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
Example #31
0
 def setUp(self):
     self._cb = psycopg2.extensions.get_wait_callback()
     psycopg2.extensions.set_wait_callback(self.crappy_callback)
     ConnectingTestCase.setUp(self)
     self.to_error = None
Example #32
0
 def setUp(self):
     self._cb = psycopg2.extensions.get_wait_callback()
     psycopg2.extensions.set_wait_callback(psycopg2.extras.wait_select)
     ConnectingTestCase.setUp(self)
Example #33
0
 def tearDown(self):
     self.clear_test_xacts()
     ConnectingTestCase.tearDown(self)
Example #34
0
 def tearDown(self):
     ConnectingTestCase.tearDown(self)
     psycopg2.extensions.set_wait_callback(self._cb)
Example #35
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self._create_temp_table()
Example #36
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        self.make_test_table()
        self.clear_test_xacts()
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.lo_oid = None
     self.tmpdir = None
Example #38
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     curs = self.conn.cursor()
     curs.execute("CREATE TEMPORARY TABLE ExtrasDictCursorTests (foo text)")
     curs.execute("INSERT INTO ExtrasDictCursorTests VALUES ('bar')")
     self.conn.commit()
Example #39
0
 def setUp(self):
     self._cb = psycopg2.extensions.get_wait_callback()
     psycopg2.extensions.set_wait_callback(self.crappy_callback)
     ConnectingTestCase.setUp(self)
     self.to_error = None