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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.4.8-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.8-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 9e4c8dc8cd3e8815f55c08f7b6cc1206ebfc3330172e9bc64288262d95627e06
MD5 6d01f926415d7017b0381565ee7ef988
BLAKE2b-256 890974e0eb863f54e5142e3eadad7dc2e27b9b17eed8087f1f9bd868a4a91533

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e2fab5ea0134a27c86e3554776c89003638d6b62bc0e2002a09e0a4628b6c09
MD5 996d304318e850ea6b3678be9251564b
BLAKE2b-256 4189479ca7e38d358286f15c11641afc361b49ec59cdf8f714bc3815f755831b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6267f9a94a9470b3a7a7a3d758b2a0bdafc13f98e87fb588824ca23f41a60ede
MD5 0e7622b5e241bb570c00d5b9d82c8812
BLAKE2b-256 3244c00c80d8c0c2451da80fba302294f6accbf9a18c20a4be9839e7b0303285

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a8c5d43f864c36e34d17e655f20d459533abfcb13de92a79b2b3dca1d5b3a305
MD5 13116f054cf2c8dd3d8aad7f4eedc0ad
BLAKE2b-256 44252692c1b05ec497041dd902d1edf3833d5fb6993154cff9351a75b64e5dbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 df167e5b5d43771395cd0008a510e69a97bdf1734f1df7a3dc4044070ab38ec1
MD5 6f9d735cfdf3c760aad2c4f90eec6fd3
BLAKE2b-256 f1b4bd66adfb6438a0c0896cea7c8a840f67e5ec60573108abeb2fc2997bc70c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fb0cc01d8414b3ba9ce4d048aa72c8f4217f697b74a7cd088de5a2773524cb6c
MD5 fa5e4a02fac0060c310a2230b07c86eb
BLAKE2b-256 9698c6338e342de4ec07bc3681eb6bada0dfd5418af8a43586f510c6bd42980e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d01e975266f068348928274958a5526e6b1160ca8bea85af19396ba48db51b39
MD5 d772ad112855be6019f09174c5a2d80b
BLAKE2b-256 6138fc0e8267f4cc642fbe807c7745ed0a2eb4a15c316aca3a58629a88095f93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d6446edf9562cbd8533d5ae1bfd3aa62a2ffe119a43a7ee53ec56fbaeae70d91
MD5 5d3be70cc4f552ba3b5879bae0786246
BLAKE2b-256 9ea1ec85429216fc531993ed30cb2f08a242dd023b0e631a3ffffa4babf1b4d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7969ab086a2980249d15b3a97bb130ea212e21c2ce7049f3545a4c44f4895c66
MD5 7e2afb4124b50f7f635af7a0d2d9cf05
BLAKE2b-256 52cc4afbdf4a0e591d07569bcb54c6be7b120f9cf4c4bc28a0d9693ee8d47e23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5c298e00e66431335c846a6e865b6172103097e94599c6a4d569dc36a9716a75
MD5 c3a513fcbf7a06095c3a4095291d0dd3
BLAKE2b-256 fdb2d2e8d828894038cc3ecbd139f62f14dc19007d8b85feb92bba4e2e033e22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0a910f169fd0c4065fa957c5ea03dd3556ead92fcf5db3740e6febbe7a857eda
MD5 07724d5d1177601aeb77da9a1b43f63a
BLAKE2b-256 e15f7790f1349a24c9a89e88e735cbdef7870b9ca3b61f6aa63bd87c38c8719d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 29012818235475b99b3411857c3cd72169e2844520c6d85aa0bd640c47a856bf
MD5 58c31d4fdcc821f000523256142f4a14
BLAKE2b-256 d6ecf4c8616e4ec03006941a42120a173c71aa9f16c3154c19446c9fef00ca60

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6ef459a257719afe9a8d8046a6232a9983357cae22305d70e34740ab9133d7d3
MD5 7758b7e9809e65cdbe8f8198bff3b7e3
BLAKE2b-256 6b8be025c29c32f68eb5430ef6cce788ea9fbd1d58cdda61233a78bb7f201d34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de573139abb72ef95d65b4cef2aa81b24bfa205dbf90d8b2e8e66e357194dfbd
MD5 2966b0bcff4d637b6b8e35f9980a40b6
BLAKE2b-256 2503c2e47798234caf9175556097858ef111b415d65210b53a4184f328555da8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35bfd26c6888d6e6f21c4d51a0496695fb44fe14ca6caf8cf1b84df15e351a81
MD5 d886e3b03d430ac5ada7b9ac9724ad90
BLAKE2b-256 a5dd2fc4ca89d963a87c512e4d64cf3ab118b9e987178b0ee88c32a7aa34006d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4d64591e847393c3bc0250ab30558531d324f9aecbae82fcadb1d34bd49d4a84
MD5 4ce3e40b3e31d4b0cdf080a488576779
BLAKE2b-256 034771cdede03254af4b698ceac93c58bcc96a583255b9923a1747aab994b6c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8ae60d88b0b34a5294978652398a8a4642bd552b3a4afdd9f183b3af827f2b2a
MD5 081f6905dbc21ff9aa07740a1c6d4d94
BLAKE2b-256 595697bc32a37ff900b212ef5d1faaf0c7910512d94136612354dfa5c8899dee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4592f8bf4ba73074f72243ce18ab8e710f13a9bc102f3ff70fa03457676943f7
MD5 c49cf5a779dc72a7f8dfec9c05de8300
BLAKE2b-256 0ba4e33288e0ee5fb8c1e44b29cdc38c52325149c912c7dc344079351e2d075d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 643373478dcfdbdf7a2264d71b16fa4585e69d4310abe1040b017951a91b7419
MD5 f3d4fdc019237c17ea864c9e0035ed8a
BLAKE2b-256 a2206fb6cc609cec94393f6713095a032cbf5f8ba122bb9a909d59e4e88a7484

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.8-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0f8300ae4e097519236e883ebfcdf722f7440fca7371ffbfecceb87cbb539ce7
MD5 332f1ac9f173c7527719eae74a44eea3
BLAKE2b-256 b85ed43178490987d75b23486dcced1ffc019bae5fef43531dc0a404099d6e7f

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