Skip to content

Writer

Writer(table, *, client=None, batch=True, batch_size=1000, database=None, settings=None, transport_settings=None)

Writer for inserting data into a ClickHouse table.

Initializes a new Writer instance.

Parameters:

Name Type Description Default
table Table[T]

The table to write to.

required
client Client | None

The ClickHouse client.

None
batch bool

Whether to batch insert records. Defaults to True.

True
batch_size int

The number of records to insert in a batch. Defaults to 1000.

1000
database str | None

The database to write to. Defaults to the database of the client.

None
settings dict[str, Any] | None

The settings to use for the insert. Defaults to None.

None
transport_settings dict[str, str] | None

The transport settings to use for the insert. Defaults to None.

None

queue_size property

The number of records in the queue.

written_rows property

The number of rows written to the table.

insert(*items) async

Inserts records into the table or queue them.

If batch is False, the records are inserted immediately; otherwise, it is queued for batch insertion.

Parameters:

Name Type Description Default
items T

Records to insert.

()

flush() async

Flushes the records in the queue to the table.