def team(): """Sample team entities.""" db = db_bind(DB_CONNECT) click.echo('writing team') with db_session: _entries = [] for _entry in _data.get("team"): click.echo(f'getting org {_entry["organization"]["bat"]}') _entry["organization"] = db.Organization.get( bat=f'{_entry["organization"]["bat"]}') _entries.append(_entry) load_entity("team", db.Team, _entries)
def domain(): """Sample domain entities.""" db = db_bind(DB_CONNECT) click.echo('writing domain') with db_session: _entries = [] for _entry in _data.get("domain"): click.echo(f'getting org {_entry["organization"]["bat"]}') _entry["organization"] = db.Organization.get( bat=f'{_entry["organization"]["bat"]}') _entries.append(_entry) load_entity("domain", db.Domain, _entries)
def allocation(): """Sample category allocation.""" db = db_bind(DB_CONNECT) click.echo('team category allocation') with db_session: _entries = [] for _entry in _data.get("category_allocation"): click.echo(f'getting team {_entry["team"]["bat"]}') _entry["team"] = db.Team.get(bat=f'{_entry["team"]["bat"]}') click.echo(f'getting category {_entry["category"]["bat"]}') _entry["category"] = db.Category.get( bat=f'{_entry["category"]["bat"]}') if db.Category_Allocation.get(**_entry): click.echo(f'skipping {_entry["category"].name}') else: click.echo(f'writing {_entry["category"].name}') db.Category_Allocation(**_entry)
def category(): """Sample category entities.""" db = db_bind(DB_CONNECT) click.echo('loading category') load_entity("category", db.Category, _data.get("category"))
def org(): """Sample organization.""" db = db_bind(DB_CONNECT) click.echo('loading organization') load_entity("organization", db.Organization, _data.get("organization"))
def create(): """Create database tables.""" db_bind(DB_CONNECT, create_tables=True)
def person(): """Sample person entities.""" db = db_bind(DB_CONNECT) click.echo('writing person') load_entity("person", db.Person, _data.get("person"))
def technology(): """Sample technology entities.""" db = db_bind(DB_CONNECT) click.echo('writing technology') load_entity("technology", db.Technology, _data.get("technology"))