@argh.arg('<STR_LIT>', help='<STR_LIT>', required=True)<EOL>@argh.arg('<STR_LIT>', '<STR_LIT>', type=to_int)<EOL>@argh.arg('<STR_LIT>', help='<STR_LIT>', type=str)<EOL>@argh.arg('<STR_LIT:-c>', '<STR_LIT>', type=to_int)<EOL>@argh.arg('<STR_LIT>', '<STR_LIT>', choices=['<STR_LIT>', '<STR_LIT:text>'], default='<STR_LIT:text>')<EOL>@argh.wrap_errors([KeyboardInterrupt, BrokenPipeError] + clients.client_errors)<EOL>def insert_json(table=None,<EOL>bulk_size=<NUM_LIT:1000>,<EOL>concurrency=<NUM_LIT>,<EOL>hosts=None,<EOL>output_fmt=None):
if not hosts:<EOL><INDENT>return print_only(table)<EOL><DEDENT>queries = (to_insert(table, d) for d in dicts_from_stdin())<EOL>bulk_queries = as_bulk_queries(queries, bulk_size)<EOL>print('<STR_LIT>'.format(<EOL>bulk_size, concurrency), file=sys.stderr)<EOL>stats = Stats()<EOL>with clients.client(hosts, concurrency=concurrency) as client:<EOL><INDENT>f = partial(aio.measure, stats, client.execute_many)<EOL>try:<EOL><INDENT>aio.run_many(f, bulk_queries, concurrency)<EOL><DEDENT>except clients.SqlException as e:<EOL><INDENT>raise SystemExit(str(e))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>print(format_stats(stats.get(), output_fmt))<EOL><DEDENT>except KeyError:<EOL><INDENT>if not stats.sampler.values:<EOL><INDENT>raise SystemExit('<STR_LIT>')<EOL><DEDENT>raise<EOL><DEDENT>
Insert JSON lines fed into stdin into a Crate cluster.

    If no hosts are specified the statements will be printed.

    Args:
        table: Target table name.
        bulk_size: Bulk size of the insert statements.
        concurrency: Number of operations to run concurrently.
        hosts: hostname:port pairs of the Crate nodes