Skip to main content

Library for read and write Native format between Clickhouse and file.

Project description

NativeDumper

Library for read and write Native format between Clickhouse and file

Examples

Initialization

from native_dumper import (
    CompressionMethod,
    CHConnector,
    NativeDumper,
)

connector = CHConnector(
    host = <your host>,
    dbname = <your database>,
    user = <your username>,
    password = <your password>,
    port = 8123,
)

dumper = NativeDumper(
    connector=connector,
    compression_method=CompressionMethod.ZSTD,  # or CompressionMethod.LZ4 or CompressionMethod.NONE
)

Read dump from Clickhouse into file

file_name = "native.zstd"
# you need define one of parameter query or table_name
query = "select ..."  # some sql query
table_name = "default.test_table"  # or some table

with open(file_name, "wb") as fileobj:
    dumper.read_dump(
        fileobj,
        query,
        table_name,
    )

Write dump from file into Clickhouse

file_name = "native.zstd"
# you need define one of parameter table_name
table_name = "default.test_table"  # some table

with open(file_name, "rb") as fileobj:
    dumper.write_dump(
        fileobj,
        table_name,
    )

Write from Clickhouse into Clickhouse

Same server

table_dest = "default.test_table_write"  # some table for write
table_src = "default.test_table_read"  # some table for read
query_src = "select ..."  # or some sql query for read

dumper.write_between(
    table_dest,
    table_src,
    query_src,
)

Different servers

connector_src = CHConnector(
    host = <host src>,
    dbname = <database src>,
    user = <username src>,
    password = <password src>,
    port = 8123,
)

dumper_src = NativeDumper(connector=connector_src)

table_dest = "default.test_table_write"  # some table for write
table_src = "default.test_table_read"  # some table for read
query_src = "select ..."  # or some sql query for read

dumper.write_between(
    table_dest,
    table_src,
    query_src,
    dumper_src.cursor,
)

Get NativeReader object from stream

table_name = "default.test_table_read"  # some table for read
query = "select ..."  # or some sql query for read

reader = dumper.to_reader(
    query=query,
    table_name=table_name,
)

NativeReader has three methods available, but only one of the methods is available at a time within a single session.

# read as python generator object
reader.to_rows()
# or read as pandas.DataFrame
reader.to_pandas()
# or read as polars.DataFrame
reader.to_polars()

Write from python objects into target table

# some table for write data
table_name = "default.test_table_write"
dtype_data: Itarable[Any]
pandas_frame: pandas.DataFrame
polars_frame: polars.DataFrame

# write from python object
dumper.from_rows(dtype_data, table_name)
# write from pandas.DataFrame
dumper.from_pandas(pandas_frame, table_name)
# write from polars.DataFrame
dumper.from_polars(polars_frame, table_name)

Open Native file format

Get info from my another repository https://github.com/0xMihalich/nativelib

Installation

From pip

pip install native-dumper

From local directory

pip install .

From git

pip install git+https://github.com/0xMihalich/native_dumper

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

native_dumper-0.3.5.2-cp314-cp314-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.14Windows x86-64

native_dumper-0.3.5.2-cp314-cp314-manylinux_2_28_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

native_dumper-0.3.5.2-cp314-cp314-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

native_dumper-0.3.5.2-cp314-cp314-macosx_10_15_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

native_dumper-0.3.5.2-cp313-cp313-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.13Windows x86-64

native_dumper-0.3.5.2-cp313-cp313-manylinux_2_28_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

native_dumper-0.3.5.2-cp313-cp313-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

native_dumper-0.3.5.2-cp313-cp313-macosx_10_14_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

native_dumper-0.3.5.2-cp312-cp312-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.12Windows x86-64

native_dumper-0.3.5.2-cp312-cp312-manylinux_2_28_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

native_dumper-0.3.5.2-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

native_dumper-0.3.5.2-cp312-cp312-macosx_10_14_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

native_dumper-0.3.5.2-cp311-cp311-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.11Windows x86-64

native_dumper-0.3.5.2-cp311-cp311-manylinux_2_28_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

native_dumper-0.3.5.2-cp311-cp311-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

native_dumper-0.3.5.2-cp311-cp311-macosx_10_14_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

native_dumper-0.3.5.2-cp310-cp310-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.10Windows x86-64

native_dumper-0.3.5.2-cp310-cp310-manylinux_2_28_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

native_dumper-0.3.5.2-cp310-cp310-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.5.2-cp310-cp310-macosx_10_14_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

Details for the file native_dumper-0.3.5.2-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 29f6b7066eb99017fb09748c4a163cc0680b8f968e455c2d7a2f284d3e12acfd
MD5 b0c857bc7c8ae81a92ffed4a3592fed9
BLAKE2b-256 345d29fbbfd4e20abe12e37b07cf03acd15d9cac1854dc0db6bc140ab6ed0c57

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f682596ec4a04118b3698d914ad210bfe708b16d84a6278e6d86bb8593fee2c
MD5 c398632b25e891989a12fb3e62647e45
BLAKE2b-256 99b01c65302a0fa65f12903a8da3afcdbdf4f2e593a3eb0efd949a6e4a9df9d5

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d1329f7932eaaba951e6acd686951533eed7cfd07bc8cde8b7494896792ba5e
MD5 ba13d232b88fe564f07dc3a4ba593c33
BLAKE2b-256 1ecb380ffcf44e3fb45a46d825f59d41f381c2d2df8717cd812e9eeed5ee7a8e

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 07f768e3775a619e595fa49554497ddbc2374d06b6847a1177e80f0b06076949
MD5 c85774a4ba1e806c82c6c08a696461a2
BLAKE2b-256 60887dbae4c13d6d6ced29af9362638d4928ebc19868fac143e42c29adc16951

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e7fdc01d758ee7637d5fe3ed988934f42b1e851401ca75f9f561cb1aedb8e645
MD5 c8de18f2ffd2c0b6dec748ed065bbed7
BLAKE2b-256 ed135f04cff20b1489062f5937fc270a12c4e45533594894adf67f758249e924

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a92d293c4b7b140370dd35c7eaec07e12d9d0ed2ce53b8ed2af260733f95bb55
MD5 1fb20efc7f839b9654f0a3bebed75536
BLAKE2b-256 0d4264e61e0f8ebd11ea51b69e6435c91b13df01e87681f00cadb5e5b4280027

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2b8ce831f54837fd4ba0b1a35facf130aa8779493faef9d77b113a4bd29aed6
MD5 aebe7105d4246dd2d4b128c659dbf02c
BLAKE2b-256 0da9053690aeedb24c0792c0cf20bd61734b92b1d804fce18465594a8d8a52ca

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp313-cp313-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c457e9a14d0effba95b52a519e454861bd63c0f90d7ae1771337c299b7f97e3f
MD5 670ce9ba65f196049fcd9d5b83de4b5a
BLAKE2b-256 bfbb20f9b62fdc671bfd29ef6d8c7675aa0b12da32a5d7cc91ed0e060bf4891a

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c66b499fe2c8c0cfc4dccabae5b128e6a6fecfa36864d5384bf0d5ca679a9433
MD5 522857d9ce4ef6a5661b9cee268b8681
BLAKE2b-256 34f64e3e459db4947471677914ed526b6273eb964b3459f9e5b22989a1af7949

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 81be2eeb94c0c280f861494301a4643cf64dabe3a072b70f2f21365fd909aacd
MD5 e1515253800e1bb9eb3e817553261b96
BLAKE2b-256 5ab9f343770aef93ddd37d236e8ce534938d4f214776a20c7fa153f3f3fd613c

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32fc174bed7702b61ad6d9f1914f4c8e4f50be6099d6a3f79528b1962485123b
MD5 c39826d925b98843ae2aca7bdd39e421
BLAKE2b-256 462724fc21be952b0d0672fb0beb293db021758f9b2db3e3e189c905959d837d

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp312-cp312-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2d0097a37c151b083c4d804716b19adee8dd76883cc19fee1e67e22654c29c5a
MD5 188f9f9fd044fd5277dbde74b95987bd
BLAKE2b-256 8d9f9399027a9f654976124d9bca885e3049c65d3183999ac694b057963a7d01

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 861936f59d8bc65985de397c22c6749df1d38f04bbecaf54913e5608e7d3086c
MD5 6e80bf5a049a1476ee0c18b7cecb25ae
BLAKE2b-256 d82e9c3592729f1f7fed748316f974e909d0313f8e075fec16250f8dc14e58c4

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c09b3000fac13d2a5d81b53a2a8d660c3e2d126cdc802a42908691b475ce0192
MD5 9d6a6394eb45c816b1781c6e01265771
BLAKE2b-256 24e41b508a9fece4264b258130f7e71c54f06a69d5e497a9526f8a3be97139a5

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e32530ab4208f3820171af5156a5acc892d077c19bfb6dd6efc37bdac731b486
MD5 c2d2561fc23815beed06492227daddf8
BLAKE2b-256 bf64d95e1eeec2b66f1c8848569b9f8de3398d29e7d52cca0cc37e3ef29eb77e

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 71b50f97e849a64bc7ce24e4b81d4348e4bcc953d8be022d72f51bd48becc82f
MD5 cbab0fab44a3829bdeb7aa001fbfe943
BLAKE2b-256 0e2033deeaf281a641765ac574e54ba84170d46482fec534db981b2dc710ed95

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fa9644995223691656abcf6491fca721d7786f27cd8218a92d28192d9617ecd9
MD5 8c6aeee4b80e70dcc8813e51d8f3a2e3
BLAKE2b-256 680d5ab21452897a228f12440625f831ad42be4d11624eb8d2c4592fbcd214e5

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76bd9e57af5342d695d1bedfc8d5170ba9c39d230c7af7183f00c1b4a9f5cbb2
MD5 875f2e7556497a0edb3af75103a07713
BLAKE2b-256 5d00981409b845bac02e6d09c24a3c4ccefc7941cd95e8bcb03aabf6bb79f604

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48a48819d173f022394a275c9e6070b1b32f4e6fa6c370f4a232d2088805d1df
MD5 a23c47df1b245745197d839b28f33914
BLAKE2b-256 dd22f17c297f49208374c68aaaf07e41eff98f6d127a2114ce7407bfcfbb8bb6

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.5.2-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 40667d3420285f7413e30276825f4c23af70aa6532ba03e0aa503d89f1990ea8
MD5 0d8462a1df9d4573e41034a9e157132a
BLAKE2b-256 9baefbcc3cde5e062872e40eee0e210b7b7edc950b55fab267549ce8bf202dd6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page