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.4.7-cp314-cp314-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.14Windows x86-64

native_dumper-0.3.4.7-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.4.7-cp314-cp314-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

native_dumper-0.3.4.7-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.4.7-cp313-cp313-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.13Windows x86-64

native_dumper-0.3.4.7-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.4.7-cp313-cp313-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

native_dumper-0.3.4.7-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.4.7-cp312-cp312-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.12Windows x86-64

native_dumper-0.3.4.7-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.4.7-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

native_dumper-0.3.4.7-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.4.7-cp311-cp311-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.11Windows x86-64

native_dumper-0.3.4.7-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.4.7-cp311-cp311-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

native_dumper-0.3.4.7-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.4.7-cp310-cp310-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.10Windows x86-64

native_dumper-0.3.4.7-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.4.7-cp310-cp310-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.4.7-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.4.7-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 510b1c84f3ae9195125fee976932ec73934a2aa8c7ef7953feaaaf91ccb64656
MD5 efc69b8c3e491d20b2d5efe217417b63
BLAKE2b-256 3fda3a92ac0dadf9ed9e694671c2aa9ed8b3e6598fd1576ab81d2cfec064a920

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a5e95c55a5759e3ea8999bd9686e1854042fb4cd6d8193cf033051a014fe70bb
MD5 3f89ff2418e8abd9f66ace4afa9fb7d3
BLAKE2b-256 d7ad0b41bd87677bd9b74b7a15e8fe56c546919bbf2b4033445c8deb0e42f056

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a3219fee0ce7776e773567bb7cf6abb6ce094df2b9dfa0653b64d6be3817ef3
MD5 89d0754b4ae399b817454c98375234b3
BLAKE2b-256 2fe8fc7fcf7e035bc9e96fbfd65ae1a042d2162769a5c94efc8056edc01d7866

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 396aca160d49a033a8cc160546be7c1dcb0d0982a3e86c9eed48145f817e27aa
MD5 6161f3edb4d05456ad028c4e1845f242
BLAKE2b-256 1853e681490446eae923b3cb4451a41bf4af6a42c6dd445ebbb6ca158b426a98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 acb0092d6bf9999d30c800bfe9db39f0b75a8efe9a053ca44fa99a711865f379
MD5 715b44712bb3c6f1fe1ed71f03b4a3d0
BLAKE2b-256 a4968c1a1d9105168961c026a54f86373b32c7a5d62a638ce7caf2e787e84107

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 746b886caebb90096486c72fef96d424b1b795ac0f28981391bf607630483e20
MD5 49f99ae2494392863e03177dd2a2b01c
BLAKE2b-256 1b6415329c83d3faf1d484cfd746d15863e6c018127b16800518d80f71d44cb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d6e53b32e94ceea815622550f44e45c8c584d5e50aba39cbf2874a57ad8c7a80
MD5 6447fcdbc71ac52a7d3747ae15100d37
BLAKE2b-256 cadf440028ca57d29cef1f598eb7f9f600ca6d0f454b91c03fcdb1c0fc3b6b8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a692b99ec2d8c61041179df6f01e1a4148774206aa55adc1f3f8c7734e637bb5
MD5 c71d9add7de7b6a322172b8680b69d98
BLAKE2b-256 4e6c5ffb2788f15c3b1d8a9f5cd7f3586a2b5b05ceaef557cdcdbcb6384861cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 953b0fd66b4d8cade32c85c881ddf30c3a90585664a657b14f14f12a6ee55611
MD5 d19704646bb9814c378698897f5fa732
BLAKE2b-256 1456789241037e769bfb1547e378f9edc3b7fd09e48bfd9c0d07de33200d4496

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5330e7cef6f192e14f517c0d27bde53f5c0360dba37b84fe4438be27e4e85c9f
MD5 e2c47cbf8b32ae26fdc77e6da165270d
BLAKE2b-256 c835fde78957f808b15461be91739680ce4a97d00834ed5487089bee27e7a499

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f74a3e8c0233cbb9791a0de03078a5b6503f3a4d3fed405985d6b2dfd1ea7ef5
MD5 025cab6b985dc4535b8d8d27779a50af
BLAKE2b-256 b8ccc7f107fce3bf619d1faa4e7d23743d8b16a726bfe994af1347a99809ef75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c99245aa2887f9e8250380c0f903d827f14fd5f182ccff980108bac47d890e8e
MD5 2ba2cc701a89ee805bf074e0776aed1e
BLAKE2b-256 7b86013173dab9a964adbea105de495c7b531f37c09bc27911b776006cb7fcd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ba2234c72a61cda0446bd60fe9ec1f9c0b9ea42606057afe45f82158c6dddc49
MD5 ee0903cbc5ace62b6ab18c8217d48c3c
BLAKE2b-256 70dae20fb2622d7d77b766d5017f847aa9c41aaa5e673ede41fb5915337ed325

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a59323a8c54bdeaafac7220c4f7fee19c71a38e70d8d804dac698f9cc4dbf0fa
MD5 a437c9e21672a7f633d528448276cc69
BLAKE2b-256 5b4724f4390562fc9b33b3c761037f29fd77c52161839e0b54209a83abebb2f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cbe4d1786f0183e98a7ee4368246a66bd9d8014a6ddf56e189aa2beb0faf1900
MD5 571429b28c2c8318ac1941863a27e276
BLAKE2b-256 e4154cc573c5c0371edab4f132f630260679f233c95d2002611cdf920a118b3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b027410e04189f98bec89899cfc7763057a1ec956b3e1d7426e724ba8b580601
MD5 b6f152b35c2c50d6a1e9bf1117028391
BLAKE2b-256 87bde3e2e522e3d344e3b9abbe24b7238a190821e8537b8ce2c45ecbebb696b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 20a6e7b5252bbbb4114ae949c894fe5dda39700a33f4d720e30e04c0c4a90266
MD5 3240e73d5dd7b6d389f3e75c371ab5ff
BLAKE2b-256 a6532286abf87a748abc0904d352b751ec20441ddc42f478f0284466a5bf8641

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76448e8e4f4f1ac0a9726cd121aa039575a0198da7a66bbc057a6fc5d8329fb8
MD5 46ee03031b28c6ab11ecf538ea2fd671
BLAKE2b-256 384fa0afa9365273438ef70e779f2cf0c18276584b7f1a155d81a35197affe98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e57976afe7a1ee59e293d9725f9b0ea322a1d788483694d2afd7edb6bac7ca57
MD5 1be2c9964eca06ae4475ea52a5b9ea5c
BLAKE2b-256 4ebc5df6a916638508b7eb210c1cda3a9ca776d5c244f1798a11412f89db9f9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.7-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 749d657b347cdcb7f76870038f37b35b6c164159bae9093cc989df23a4ca6c28
MD5 f8948d5739e38de5d804bdd3223612ec
BLAKE2b-256 dc5664b128d7f3e80bdb1546a42ab68a68f0ea935354a669c3fcb35cce4bc809

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