-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtry-treedb.py
executable file
·51 lines (31 loc) · 1.04 KB
/
try-treedb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# flake8: noqa
"""Some ``treedb`` usage examples."""
import pathlib
import pprint
import sqlalchemy as sa
import treedb
DBFILE = None # pathlib.Path('treedb.sqlite3')
#treedb.configure_logging(level='INFO')
treedb.configure(log_sql=False)
treedb.set_root('../glottolog')
pprint.pprint(dict(treedb.iterlanguoids(limit=1)))
engine = treedb.load(DBFILE)
assert treedb.engine is engine
treedb.check() # run sanity checks
treedb.print_rows(sa.select(treedb.Languoid).order_by('id').limit(5))
query = treedb.get_example_query() # big example query containing 'everything'
qf = treedb.pd_read_sql(query, index_col='id')
if qf is not None:
qf.info(memory_usage='deep')
lf = treedb.pd_read_languoids()
if lf is not None:
lf.info(memory_usage='deep')
#treedb.write_csv()
#treedb.write_languoids()
#treedb.write_files()
import treedb.raw
pprint.pprint(dict([next(treedb.raw.fetch_records())]))
#treedb.raw.write_files()
#treedb.languoids.files.roundtrip()
treedb.print_rows(treedb.get_languoids_query(limit=1), pretty=True)