def main(config):
    cfg = cliconfig(config)
    session = SessionFactory(cfg['database']['url']).create()
    client = MongoClient(str(cfg['mongodb']['url']))
    db = client[str(cfg['mongodb']['database'])]
    collection = db.address_jp
    collection.drop()
    q = session.query(Address).filter(Address.prefecture is not None)
    q = q.order_by(Address.zipcode)
    for r in ifilter(lambda r: r, imap(transform, q)):
        collection.insert(r)
def main(config):
    cfg = cliconfig(config)
    session = SessionFactory(cfg['database']['url']).create()
    server = Solr(str(cfg['solr']['url']),
        http_user=cfg['solr'].get('username'),
        http_pass=cfg['solr'].get('password'))

    documents = []
    q = session.query(Address).filter(Address.prefecture is not None)
    q = q.order_by(Address.zipcode)
    for r in ifilter(lambda r: r, imap(transform, q)):
        documents.append(r)
        if len(documents) >= COMMIT_UNIT:
            server.add_many(documents)
            documents = []
    if len(documents) > 0:
        server.add_many(documents)
    server.commit()
def main(config):
    cfg = cliconfig(config)
    session = SessionFactory(cfg['database']['url'], True).create()
    session.commit()
def main(config, **kwargs):
    cfg = cliconfig(config)
    session = SessionFactory(cfg['database']['url']).create()
    clistream(session.add, JPAddress._make, mapping, lambda e: Address(**e),
        delimiter=',', **kwargs)
    session.commit()