db.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:bark 作者: kylerbrown 项目源码 文件源码
def add_root(root, db_connection_string, events=False):
    db = dataset.connect(db_connection_string)
    root_table = db['root']
    entry_table = db['entry']
    dataset_table = db['dataset']
    column_table = db['column']
    if events:
        event_table = db['event']
    root_table.upsert(root_to_record(root), ['path'])
    for entrykey in root.entries:
        entry = root[entrykey]
        entry_table.upsert(entry_to_record(entry, root), ['path'])
        for dsetkey in entry.datasets:
            dset = entry[dsetkey]
            dataset_table.upsert(dset_to_record(dset, entry), ['path'])
            for column in dset_columns_to_records(dset):
                column_table.upsert(column, ['path', 'name'])
            if events and isinstance(dset, bark.EventData):
                for event in events_to_records(dset):
                    event_table.upsert(event, ['path', 'index'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号