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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.5.0-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.0-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 eb00d8a60610985fd81d04d97266d5616e7001640db88d5d5b3f924008a4bfb4
MD5 52d9b6abec06aea49175e9dea7eabe57
BLAKE2b-256 00e276fa69f46743f3036a3ce9281787b418700bbde9bae954f0611a343f1a74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 188de7e91fe2da14e326232c0142234bcd29940ddb44b98ec8366abbc5d1eae2
MD5 ca41b58e328eb2dc780ab0f176c7302a
BLAKE2b-256 4f5115a56afb1d5a672479accf514df33b9fa4a7abfeed15a6972c432ea6f750

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36795960b452073de73a21d79a3ce47c579147e301e3f3f5a9e954279a530594
MD5 532ebddda289030cee6ca820d2fe7edb
BLAKE2b-256 7641f98eaa3e3c0aad7c1215c05acbd81b4e4abdf40196a28a169f3085650061

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 43f2c5cafd9e142dddd9ddcdc632064640c3ddcaea281e6dda4d9b93d4a6cfb8
MD5 fde66324af7e6b532fa3420bcce195c9
BLAKE2b-256 a8aad3cd376a6a488b497e920dd09a8827a94f2d4e109e048366f7c1d134d15f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 456b85db95cc196efb03d19e65e256cc2a285dac42b92857865f092fbdc1a49e
MD5 a62c8f9eb3f945612eb815fdbda46090
BLAKE2b-256 c49e6809a85fad6e0a964592546b109f8f7f353858d3b047d695562011b60ea6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 549b90be78a239a6d651f6b6a1f4ed18dd7babaa7e6d3f62c6221b63aaecdc2d
MD5 6264681a3c9aedaf42aebae407811c9d
BLAKE2b-256 69f2ced8eb8a4eb8082fa299543d75d2c23d125d0c46876eb059070626a3e5e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12a09e39aad9fb3ff0bdd2803335fc28cc10c9387d798119951001ba4e57042a
MD5 29ccb05be6d2d8d3981548287a8fceb6
BLAKE2b-256 436cf4de3fd0c2b790f35c2e7571a8dd92a79e0aa1b47e55cfd74fd240e4e5e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1f608ef152a7ff3df8897c9e30aa9cee5ceea169358bfc658a1742fd669e7b6e
MD5 4260076faeaae0b55a41ae48a1932d17
BLAKE2b-256 ef407a83018e2ee75cd2566e74e3e907180f6f9c6a9cceddb4b69df64de388cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f7f533326b7716601ffc72fea76a18ab27d7f6e3e310a968beb6539e0b08247b
MD5 cae546689361fca2dd72156612960ca1
BLAKE2b-256 cda0dcec5be03dfaf9ca05d3f9c65bb54a78538033d82baaace75212e16ed2c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 781519d3093aa34f0f3c3cc932d55647bcf450fa966f61f7c497a8751232e693
MD5 eb1b31a716203f66ccef1015cf8c23a3
BLAKE2b-256 d6e68012c766460f812a0173d474ee1c8a47c776f1b5301f7dbfcef888e0fb6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d9a108477c6164fb48494bc7cafe8ff40e96bcd14c96b2c8e29443ed8ec4c73
MD5 58d58d5f4166fe7aef0991cf16941670
BLAKE2b-256 f51c2ed8d1f8020d5f5dbf5e01be06b58fd76b71c9caa4adac4216e7b8c6449c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 38ce92a1747dd3197e1ff220dff7b809082082983e9fd6bb492efa7fc9f32750
MD5 df4d417e9b9874ddad5d57c3395267fb
BLAKE2b-256 6ef16c2f31d910b1672c6b15ca3bc3f3c7431165628e539f2b017f29e3c968b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c7200051e94f0d8cd40b15d75c007382fef75b73c45a568d32f46735c92120a6
MD5 e8a86d9c0d0d7708262217b9fe8af246
BLAKE2b-256 fd7d1f099bb2d64be3ef7e93c38bdbc8e47b39f9384a4c8080c8bf342f96edcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8984e69529b7287c950c5c7a195ebc5e0ad8e1d46e834ff12f5895beb52c3774
MD5 4612033cc4f8d298136eb591358290a2
BLAKE2b-256 928e562a71fec7d2acabcf4ed7bcb784a9d291f345c86a56f36216bccbec2ce2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 524b53f614662cbc15be4134e01d78b6592bcdaa0ee6f5c0f438eab12709ef17
MD5 23fd954d3d8231c5e6c4f402e4d3435c
BLAKE2b-256 eed2e24e24723d630e6fbe81b3f6bd6fc90a8b545b59c597acd593a67c3f7b50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 69f138e7ac17834bcbc4483b41543886d642057bd2697825d5c85491540e3401
MD5 34fa567f7a62aed7dbed15390ff786c2
BLAKE2b-256 f3924a1e2c67313fe5dc328a4ff0432146c8ff61b342b7e97996aeae4bb67c16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 656d66a66938b586bed1fff47fe4502f4ed61488ba4f80a6fba812183a2d3d6d
MD5 09174d615da8259f2062503e8bf53b84
BLAKE2b-256 2ca845a2bdc01f49c4c678c293c9daedc5a9efa5fb54df3da136734f7144371c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e183ef8f83affe2b64e775ccf172de81dc03e604f75e6ec12f1a2b404f82cfd
MD5 027132f99f93fe5cf8affcb11453493b
BLAKE2b-256 6c51d7797d0a47996a3cf2abe21d80c5e923c62c83e51dcb455a16b5ae7be707

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95c037625d1530b8d9d4a17da19636394f1bca6cec6f71b25b38d85d730ce4bb
MD5 9e23ab9b09942f72baf2d15bc201fab6
BLAKE2b-256 e51d425bc4c06a4f8393a5f5ddb7f054a20d6650a267522d3ee413c3dcbc9941

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8f24e3138571e9711a2f4fc4a8c38cfca3cb8f5c4a404a91ae2f4d938926f402
MD5 adebae3b707ed5cacbb43c4deb78b503
BLAKE2b-256 1d94a14ed2ee5dac8ea9fb57404dac40dd3532e79ba4be662aff4d19560ddb0a

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