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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.4.1-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.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 11273c916a27701fa0e1ed89cda98455f19014565199f67caff4ca30be16d442
MD5 f3b55662393936a130c5f270ecae57ca
BLAKE2b-256 7a937264d4c635aa3d564412e56b786bfd0b8544555d1dd532e787a9d97f46e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c8792438a797126f96346893b0e430447e3d2a937f592f366272b4fb7615ee51
MD5 766ecb232357d9599fa174b42e483fd0
BLAKE2b-256 1375505cc0818ba7c06c2a5725aa79ad41d4d4c73c8ed6df3ed560b2311e9958

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0dfb091ea5f9effe5554ebb6f20b352ec52431800b6795a7bac64096407ba199
MD5 74f3ae05a2c3aaa58f7897616025aa21
BLAKE2b-256 c506c64534c6a8ca7fc767874fdb775c04a72b65dcfedd60e48de90c56163dfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 985c62c1679c2f1198bce146ae1369d439fdb3947c23ba01588fc8eeee55996e
MD5 61a99cea8eba2e5840eaa2bf80343ee0
BLAKE2b-256 98952bf03cc058e3eb0b74a661a2f9105ea828a498164d5f74afa04aa1790b7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 948b2c8d25a3dc136505baabb3f718841e0247c2fe03dddc92425f98aa2fbb80
MD5 b5b739bdd41ac38e2ebc19156edfb170
BLAKE2b-256 a94a5877efac4b298b1467c3964f4d1502ef03f8ff26d8a53827211c9d3be86d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c21187007199b2c86fb222641a496995cbb15ff0555883f3ea6b15ad4aaf7382
MD5 57f6d63df7f8905e8735a9418c65e6f3
BLAKE2b-256 15f44c9da5ce8efea4b3a02a56fd05bcf1706ea96411749a9bbb3a71771cc981

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5710185faa88677030535bd67f79d14edb6c9c96bfc444d1e55729e8f1b0f50e
MD5 504850488307a02cb81d7faf7c99c6c9
BLAKE2b-256 315d63de334a3e9ba9df8def98fb183dfa8a2cf82997edd0069d2fb45c851f6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 e858782fa06c5ce51f0b3bdfec4f58c0aa758a867b9292738446c6d3165fc2a8
MD5 205f6eb35cfd03868d111c3f573846a8
BLAKE2b-256 29287b905d269bb8311e0b376764f92c48b64b21f0cea41bfc40a179f1b24a65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d9bcd640770063413872b9fc035699f7367226c20f3e963f9bb244578b792df8
MD5 d124664967aef7e495370ed347415788
BLAKE2b-256 d12ba971a5a3ed98033424233ebe0d2b2cf46148bf1b79d208abec8adacaba88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0457cc7254c564d7501be13078eec7712b28ef7b834725a8ac4b2a2847e5e04a
MD5 2e2937eba383ac11540f2c9c36adf9dd
BLAKE2b-256 ed332c8bb2a95d9a8d5b342657df19d51e299bead1f3ba7cc4936ca6ec93b2da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3c9c0bf229f199d4088e77f58575dc77d4df70a2f9dd06d34db63095fbb6f4e6
MD5 c55a5c2d48a7bb99c47ea790aed24081
BLAKE2b-256 3c3fecf12cea1ca02632b636133f4d132312dc826041b541eee084e25f8ad91d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 51eb359629a4e2f4c137c610d2b4123dd1560489fb55188065b36299f87dcb94
MD5 2f49ea5febbe522681f35b6f254226e3
BLAKE2b-256 97c4be9c37ec431ce2b493cf284fc933517b295d12105732421ba1ef78065793

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4b49714ab03551b59dd1e6bd0dc45da2e1d063caa03018271b77f3917c99bf36
MD5 4661f4b1e8e72ecece489c3e3cb54ad5
BLAKE2b-256 7cd4708dc08165638c6c4f27ca8338f3750284256c2d8deacddc22b7ed4fc627

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 732016a946345ddf67e626b5f99f1866f26c63905718f492bc4217e05ab858dd
MD5 d174ab139d1437966d14b894d1b584ad
BLAKE2b-256 c1de6c69d3620cf3f28711cffe02d915fc38bcffea74959dd2cf0c3641a3b192

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4eaef7b167df10b224d6a95a3f917c960b6260f0e2893cd02c709ba1eaa7f145
MD5 b1d9841d1cb5c056bec26e3e62c6c61b
BLAKE2b-256 c2f4ac8650562ce2e16276efc158706b00414864175b5aa9363c4d9c9aa6f577

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9c7d72d23ba02c1d712bdfce56db55a7b4fa8b705f394b6568176471f95378a8
MD5 8f83ae7596c24341a0c54ebdaaf02ab9
BLAKE2b-256 7651ba766a62e04bb8880d542d600dcfcd762f71547bac95c4ec005be6856a80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 58b641692b5ae6dee4cd7019c93c7c937bcc8d2860c47f4355d0f68f79c767fa
MD5 f19ff721e7aba58040a5b57a964e2e5c
BLAKE2b-256 f1dc02db96b16989a8320e6477ca6ae9cc6f2901093f0638f42dfee9d461feee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 569e8cd0993ab83056d7a22e8958ae0566a94eb5a68cd655b6823dc0d6c3cb4e
MD5 067d8c7cb24ae1815ac8815cc20ea857
BLAKE2b-256 5306a688fd4e3909fd84a9feadbeb94dca16d541ababa23867e520fa9d35d164

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5cc19563826ff40a7bd3298dab4527bfe0d5177eb9c5cf3f762d89ac3793de61
MD5 8861be043ce6da4be1227a50169ea788
BLAKE2b-256 54fdac917ce80e34f2485a56088d2ea0052c381f3f7939dafdffedf0306f5a5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 3c8747f1a39953f41c33cb712391f76547ac49091866a41063fea5184fec5894
MD5 6274198ec0e6d9e81e6a8a132a8ae4e1
BLAKE2b-256 b319c18f50424924e0fc12ca4d8040d79bcada70745dea4197cc5ed370f5471e

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