Esempio n. 1
0
def print_stats(bind=_backend.engine, execute=False):
    query = sa.select([
            Option.section, Option.option, sa.func.count().label('n'),
        ], bind=bind)\
        .select_from(sa.join(Option, Value))\
        .group_by(Option.section, Option.option)\
        .order_by(Option.section, sa.desc('n'))
    _backend.print_rows(query, '{section:<22} {option:<22} {n:,}')
Esempio n. 2
0
def print_fields(bind=_backend.engine):
    has_scalar = (sa.func.min(Value.line) == 0).label('scalar')
    has_lines = (sa.func.max(Value.line) != 0).label('lines')
    query = sa.select([
            Option.section, Option.option, has_scalar, has_lines,
        ], bind=bind)\
        .select_from(sa.join(Option, Value))\
        .group_by(Option.section, Option.option)\
        .order_by(Option.section, Option.option)
    print('FIELDS_LIST = {')
    _backend.print_rows(
        query,
        '    ({section!r}, {option!r}): {lines},  # 0x{scalar:d}{lines:d}')
    print('}')
Esempio n. 3
0
            .filter_by(parent_id=Languoid.id).as_scalar() < 2)


@check
def bookkeeping_no_children(session):
    """Bookkeeping languoids lack children (book1242 is flat)."""
    return session.query(Languoid).order_by('id')\
        .filter(Languoid.parent.has(name=BOOKKEEPING))\
        .filter(Languoid.children.any())


if __name__ == '__main__':
    load()
    print(next(iterlanguoids()))

    _backend.print_rows(sa.select([Languoid]).order_by(Languoid.id).limit(5))

    tree = Languoid.tree(include_self=True,
                         with_steps=True,
                         with_terminal=True)
    _backend.print_rows(tree.select().where(tree.c.child_id == 'book1242'))
    _backend.print_rows(tree.select().where(tree.c.child_id == 'ramo1244'))

    print(next(iterdescendants(parent_level='top', child_level='language')))

    query = get_query()

    try:
        import pandas
    except ImportError:
        pass