Esempio n. 1
0
def table_source(db, tblname, schema=None):

    tbl = initialize_table(db, tblname, schema)

    def _read(**params):
        stmt = tbl.select(**params)
        return _select_iter(db, stmt)

    return _read
Esempio n. 2
0
def table_target(db, tblname, schema=None, **kwargs):

    tbl = initialize_table(db, tblname, schema)

    def _write(source):

        with db.begin() as conn:
            ins = _compile_insert(tbl, **kwargs)
            results = conn.execute(ins, [rw for rw in source])

            return (dict(rs) for rs in results)

    return _write