Files
connect/examples/write_into_file.py
Joe SpadolaandGitHub 55dcd7db4c Replace pylint with ruff for linting and formatting (#703)
* migrate from pylint to ruff

* ruff format/lint switch over

* add formatting commit

* update changelog
2026-04-02 16:09:59 -07:00

11 lines
442 B
Python

import clickhouse_connect
if __name__ == "__main__":
client = clickhouse_connect.get_client()
query = "SELECT number, toString(number) AS number_as_str FROM system.numbers LIMIT 5"
fmt = "CSVWithNames" # or any other format, see https://clickhouse.com/docs/en/interfaces/formats
stream = client.raw_stream(query=query, fmt=fmt)
with open("output.csv", "wb") as f:
for chunk in stream:
f.write(chunk)