Exemplo n.º 1
0
    def tearDown(self):
        curs = self.conn.cursor()
        curs.execute("DROP TABLE table1")
        curs.execute("DROP TABLE table2")
        self.conn.commit()

        ConnectingTestCase.tearDown(self)
Exemplo n.º 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)
Exemplo n.º 3
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
Exemplo n.º 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
Exemplo n.º 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()
Exemplo n.º 6
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        cur = self.conn.cursor()
        cur.execute('''
            CREATE TEMPORARY TABLE table1 (
              id int PRIMARY KEY
            )''')
        self.conn.commit()
Exemplo n.º 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()
    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()
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
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 psycopg2cffi.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()
    def setUp(self):
        ConnectingTestCase.setUp(self)
        from psycopg2cffi.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()
Exemplo n.º 14
0
    def setUp(self):
        os.environ["PGDATESTYLE"] = "sql, mdy"
        
        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)
Exemplo n.º 15
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)
Exemplo n.º 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)
Exemplo n.º 17
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()
Exemplo n.º 18
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()
Exemplo n.º 19
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)
Exemplo n.º 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()
Exemplo n.º 21
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()
Exemplo n.º 22
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.lo_oid = None
     self.tmpdir = None
Exemplo n.º 23
0
 def setUp(self):
     self._cb = extensions.get_wait_callback()
     extensions.set_wait_callback(extras.wait_select)
     ConnectingTestCase.setUp(self)
Exemplo n.º 24
0
 def tearDown(self):
     ConnectingTestCase.tearDown(self)
     extensions.set_wait_callback(self._cb)
Exemplo n.º 25
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self._create_temp_table()
 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()
Exemplo n.º 27
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
Exemplo n.º 28
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.lo_oid = None
     self.tmpdir = None
Exemplo n.º 29
0
 def tearDown(self):
     self.clear_test_xacts()
     ConnectingTestCase.tearDown(self)
Exemplo n.º 30
0
    def setUp(self):
        ConnectingTestCase.setUp(self)

        self.make_test_table()
        self.clear_test_xacts()
Exemplo n.º 31
0
 def connect(self):
     conn = ConnectingTestCase.connect(self)
     conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
     return conn
Exemplo n.º 32
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
 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()
Exemplo n.º 34
0
 def setUp(self):
     self._cb = extensions.get_wait_callback()
     extensions.set_wait_callback(extras.wait_select)
     ConnectingTestCase.setUp(self)
Exemplo n.º 35
0
 def tearDown(self):
     ConnectingTestCase.tearDown(self)
     extensions.set_wait_callback(self._cb)
Exemplo n.º 36
0
 def setUp(self):
     ConnectingTestCase.setUp(self)
     self._create_temp_table()
Exemplo n.º 37
0
 def connect(self):
     conn = ConnectingTestCase.connect(self)
     conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
     return conn