Ejemplo n.º 1
0
 def test_many_sql_statements(self, initialize_monetdblite):
     for i in range(5):  # FIXME 1000
         conn = monetdblite.connectclient()
         monetdblite.sql('START TRANSACTION', client=conn)
         monetdblite.sql('CREATE TABLE pylite11 (i INTEGER)', client=conn)
         monetdblite.insert('pylite11', {'i': numpy.arange(10)},
                            client=conn)
         result = monetdblite.sql('SELECT * FROM pylite11', client=conn)
         assert result['i'][0] == 0, "Invalid result"
         monetdblite.sql('DROP TABLE pylite11', client=conn)
         monetdblite.sql('ROLLBACK', client=conn)
         del conn
Ejemplo n.º 2
0
 def test_many_sql_statements(self):
     for i in range(5):  # FIXME 1000
         conn = monetdblite.connectclient()
         monetdblite.sql('START TRANSACTION', client=conn)
         monetdblite.sql('CREATE TABLE pylite09 (i INTEGER)', client=conn)
         monetdblite.insert('pylite09', {'i': numpy.arange(10)},
                            client=conn)
         result = monetdblite.sql('SELECT * FROM pylite09', client=conn)
         self.assertEquals(result['i'][0], 0, "Invalid result")
         monetdblite.sql('DROP TABLE pylite09', client=conn)
         monetdblite.sql('ROLLBACK', client=conn)
         del conn
Ejemplo n.º 3
0
    def test_connections(self, initialize_monetdblite):
        # create two clients
        conn = monetdblite.connectclient()
        conn2 = monetdblite.connectclient()
        # create a table within a transaction in one client
        monetdblite.sql('START TRANSACTION', client=conn)
        monetdblite.create('pylite05', {'i': numpy.arange(100000)},
                           client=conn)

        # check that table was successfully created
        result = monetdblite.sql('SELECT MIN(i) AS minimum FROM pylite05',
                                 client=conn)
        assert result['minimum'][0] == 0, "Incorrect result"
        # attempt to query the table from another client
        if not PY26:
            with pytest.raises(monetdblite.DatabaseError):
                monetdblite.sql('SELECT * FROM pylite05', client=conn2)

        # now commit the table
        monetdblite.sql('COMMIT', client=conn)
        # query the table again from the other client, this time it should be there
        result = monetdblite.sql('SELECT MIN(i) AS minimum FROM pylite05',
                                 client=conn2)
        assert result['minimum'][0] == 0, "Incorrect result"