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()
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
def test_creates_session(self): db = Database('sqlite://') db.open() self.assertIsNotNone(db._session)