示例#1
0
    def test_table_basic(self):
        """Basic operations on datasets"""

        db = Database(self.dsn)
        db.open()

        ds = db.new_dataset(vid=self.dn[0], source='source', dataset='dataset')
        ds.new_table('table1')

        db.commit()

        t1 = db.dataset(ds.vid).table('table1')

        t1.add_column('col1', description='foobar')

        db.commit()
示例#2
0
    def test_table_basic(self):
        """Basic operations on datasets"""

        db = Database(self.dsn)
        db.open()

        ds = db.new_dataset(vid=self.dn[0], source='source', dataset='dataset')
        ds.new_table('table1')

        db.commit()

        t1 = db.dataset(ds.vid).table('table1')

        t1.add_column('col1', description='foobar')

        db.commit()
示例#3
0
    def test_a_lot_of_tables(self):
        from contexttimer import Timer

        db = Database(self.dsn)
        db.open()

        ds = db.new_dataset(vid=self.dn[0], source='source', dataset='dataset')

        with Timer() as tr:
            for i in range(100):
                t = ds.new_table('table' + str(i))

                for j in range(10):
                    t.add_column('col' + str(j), datatype='integer')

            ds.commit()

        print(len(ds.tables), len(ds.tables) / tr.elapsed)

        self.assertEqual(100, len(ds.tables))

        for t in ds.tables:
            self.assertEqual(11, len(t.columns))  # 10 + id column
示例#4
0
    def test_a_lot_of_tables(self):
        from contexttimer import Timer

        db = Database(self.dsn)
        db.open()

        ds = db.new_dataset(vid=self.dn[0], source='source', dataset='dataset')

        with Timer() as tr:
            for i in range(100):
                t = ds.new_table('table' + str(i))

                for j in range(10):
                    t.add_column('col' + str(j), datatype='integer')

            ds.commit()

        print(len(ds.tables), len(ds.tables) / tr.elapsed)

        self.assertEqual(100, len(ds.tables))

        for t in ds.tables:
            self.assertEqual(11, len(t.columns))  # 10 + id column
示例#5
0
 def test_creates_session(self):
     db = Database('sqlite://')
     db.open()
     self.assertIsNotNone(db._session)
示例#6
0
 def test_creates_session(self):
     db = Database('sqlite://')
     db.open()
     self.assertIsNotNone(db._session)