def test_insert(transformed, tmpdir): t = transformed expected = execute(t) tpath = tmpdir / 'new_dir' tpath.mkdir() path = tpath / 'foo.h5' assert not path.exists() t = transformed[['time', 'ticker', 'avg']] c = ibis.hdf5.connect(tpath) c.insert('foo.h5', 'avg', t) execute(t) assert path.exists() # readback c = HDFClient(str(tpath)).database() result = c.list_databases() assert result == ['foo'] result = c.foo.avg.execute() tm.assert_frame_equal(result, expected) path = tpath / 'foo.h5' assert path.exists()
def hdf(tmpdir, data): from ibis.file.hdf5 import HDFClient hdf = tmpdir.mkdir('hdf_dir') f = hdf / 'prices.h5' for k, v in data.items(): v.to_hdf(str(f), k, format='table', data_columns=True) return HDFClient(tmpdir).database()
def test_client(tmpdir, data): # construct with a path to a file hdf = tmpdir f = hdf / 'prices.h5' for k, v in data.items(): v.to_hdf(str(f), k, format='table', data_columns=True) c = HDFClient(tmpdir) assert c.list_databases() == ['prices'] assert c.database().prices.list_tables() == ['close', 'open'] c = HDFClient(tmpdir / 'prices.h5') assert c.list_databases() == [] assert c.list_tables() == ['close', 'open']