コード例 #1
0
    def runTest(self):
        table_name = "update_table"
        p = PolyhedraDatabase('tiberius-polyhedra')
        try:
            p.create(table_name, {'id': 'int primary key', 'column': 'int'})
        except PolyhedraDatabase.TableAlreadyExistsError as e:
            print "Table already exists"
        p.insert(table_name, {'id': 0, 'column': 0})
        p.insert(table_name, {'id': 1, 'column': 2})
        p.insert(table_name, {'id': 2, 'column': 4})
        p.insert(table_name, {'id': 3, 'column': 6})
        p.insert(table_name, {'id': 4, 'column': 8})
        # TODO: Validate output
        initial = p.query(table_name, '*')

        # Update all the rows with different values
        p.update(table_name, {'column': 1}, {
                'clause': 'WHERE',
                'data': [
                    {
                        'column': 'id',
                        'assertion': '=',
                        'value': 0
                    }
                ]
            })
        p.drop(table_name)
コード例 #2
0
    def runTest(self):
        table_name = "test_table2"
        p = PolyhedraDatabase('tiberius-polyhedra')
        try:
            p.create(table_name, {'id': 'int primary key', 'column': 'int'})
        except PolyhedraDatabase.TableAlreadyExistsError as e:
            print "Table already exists"
        p.insert(table_name, {'id': '0', 'column': '0'})
        p.insert(table_name, {'id': '1', 'column': '2'})
        p.insert(table_name, {'id': '2', 'column': '4'})
        p.insert(table_name, {'id': '3', 'column': '6'})
        p.insert(table_name, {'id': '4', 'column': '8'})
        # TODO: Validate output
        p.query(table_name, '*')
        p.drop(table_name)

        p.create('complex_table', {'id': 'int primary key',
                                   'name': 'varchar(50)',
                                   'address': 'varchar(200)',
                                   'robot_id': 'int'})
        p.insert('complex_table', {'id': '0',
                                   'name': 'Cameron A. Craig',
                                   'address': '1979 Hannover Street',
                                   'robot_id': 0})
        # TODO: Validate output
        p.query('complex_table', '*')
        p.delete('complex_table')
        p.query('complex_table', '*')
        p.drop('complex_table')