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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.4.9-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.9-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 df42960bbd5ec413b94800e642de2032ce31aef11472e8ee20bf6862049f93e5
MD5 afc8477c7e66ad7cd96b929650e0c836
BLAKE2b-256 8b9d831d0dd2afec8231f322da374cf6790a08d999e912782c00546c0055259a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bc45386af52d41e9e13917fa1d4e2cd4d7ff74f6779a6e545de57018f75618e9
MD5 86ad467d59e0ff4d28fd61ff1d8ad8e0
BLAKE2b-256 dfb8c0d735663e0da4c3b7a45debb3ea4217fbc29e5f11dead29975cdeca0d7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e9d62e3ff4360f14848e87d632505eace11c0dec54d37630cda30c1c4b2b92b
MD5 9cb51a21a28ae2c945884c3a70b7a718
BLAKE2b-256 ba55a651c5513fc4f9a77cce3e31b9abd941bc53976d7bda299f6145e044f8fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 47e17e7d242019e68953c8cdb30ac701bba51a6cce6b1180a86492f198a9cb03
MD5 10613e2656d564a5d64da27abc00a4aa
BLAKE2b-256 bfda4439a673b1c246608d9dc63d470453c2e8245e8a979bc864c68ffba5a49e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fd733392679563ad0f3b3dae3b164cccbe1d76b6af4bcfef1e137b62bfc599c3
MD5 dc50bdd7cda4c7df129746356a1f498f
BLAKE2b-256 209ac832c12a54a84d21700461448b59a85a87c1970168ee82013be978f2853e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8a84de167596507649839dc0ba662b358a99b02f543c864e4242909fc0aec3a8
MD5 e39ec63d936e743af1977b2b8664c16b
BLAKE2b-256 84bc66e481ed8e929ca15941c5b1aaa69303f74da28140bf280c9c53e8b120bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03fdc0a21b552a64860cc158f1c3266ecf023e1c78db4de7999d053f4b52841f
MD5 6cb37587c5b3682498fba091e81c1dc0
BLAKE2b-256 6b29b2e52bd2e02c0ad70fef532172b4b1edd0b1a069f5483084b0b173471529

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 acf64d0dc6c1422548eb81c2a21b5d4e047fc8b3069ad5e21e1c5203872bcc9e
MD5 5e1e7a651566c5994d4e7de8a3ff2450
BLAKE2b-256 6cf3010d675ff6944087d107fbba9807761d7d810165122c9a93819bbace3adf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8568c70d492435beeacb0bbaadb34c2bb87796cb93fbc7ecfb7a12bee590772e
MD5 322f47e5af2e2eafd749c8e1b8c1cbfe
BLAKE2b-256 9d5458b7908d402d53656186dc183b0c220de420e15a8bec7cfdaece68a0a773

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0bb7ea8e52b2ee3c1e41808806d57797de3014c605f5837604bf04d6a06441da
MD5 03e003149ad8e3a033a1268e55b0b75e
BLAKE2b-256 15a8e8a995d8aaa1ccab202c5c931c7c6620830a96664407f06c6dad71451595

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0cd04d72f8c8de07e743298084c63e7a668f1d6e6ca6a87de46b94b904304ba9
MD5 74008a3b9226d8f013a1648aada58910
BLAKE2b-256 afa74a8ab2388a4f0f989414b947dab6bb84d7c2117b95ee5fb33a1040d891a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2900e248d227a7c6af589a5029a42466d35abe17634a8fba5b9b0b6e416d3134
MD5 e21f00d191ba51cc4a25fbab70118c9b
BLAKE2b-256 28d2c8137ff93a8642b4e81ff7a56c1f1fd3e9608b2fcf01eab8caf4a6edbc9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9b98e218adc06e5a109117106735646ceebf40ca82156386564b13bc09bdce14
MD5 efa6b106896089dd8336a127301a5a05
BLAKE2b-256 e716e152c7a996dc5777c4f1df6ba2cd9c54ff6ef113b12ab265cc1f0ed55d11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e81cde8f61dc6204125fdfaf19c4c72b1f766f8326e4d7205cb3f50a88f949cf
MD5 5e420ef009d431a90c2b49a67b4ce3ef
BLAKE2b-256 a253babaaff61e02c3b496bf71d2bb2b6a67a5fcd5fcbca20c5d99b5773d3f36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ccbb2b82684ba5a08d4ab7a6a91d62cefa796afdba1f865c42a90b2f5425cf9
MD5 99f5aa2fc71c36a41c5265d46d03c03a
BLAKE2b-256 2d443b8083e31858a45d5341edd92f55bab80a7b5499a8571acf0eaa0b1e3cb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c0a4a0ac0d6c67180b7f0d8caa3444a473258f7eb8e44084602045b4adb1966c
MD5 adb28ae339aec83ea90d081e2cd4be70
BLAKE2b-256 bc04ccc51b932cb7817147b3cfa02997dabefefde0d0c5c67b141f46cadf1596

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7cc9b4d8d5131d909f2942565ef0834cda773e54f69350893ab8ee7e70da2e96
MD5 912eafaf0be4151ec0b225519135a86e
BLAKE2b-256 4f7568bb2da2cb4f148b1511f929c79141b17e7ec19a90c89c1e2426dd49b5a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3929bec9f53e0a93dd4009bb26fd282f10fcfa494e16f0ec8b25565570d2dbba
MD5 6127354058f8f1c5ec37be6f4e38f368
BLAKE2b-256 7086b99fda7c0cf2a37209131f7d7cd8a204f992f7f0bcb4fd4b1b13134ba05b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 366518341417c4dbf60c973ac109949d305291f8454982bd04edcfa025f0b4fb
MD5 ffb0e747e39907b940972ff71ade209a
BLAKE2b-256 4bbc5eb07e10ec40487bcc96db9365d8698d85407dd8be8a8edd0dc9bb068a87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.9-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 25ed36fe030ce5dd89a2fe236e2f835cba34cfe16419ca4f93699c86048888b3
MD5 21751a292447ee72743d5f0d7adfb500
BLAKE2b-256 87f16477e4ff566df888c0b456e00aa8dd8ed2b2e02c26ea39faff42011bdcbc

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