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 Distribution

native_dumper-0.3.1.1.tar.gz (28.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

native_dumper-0.3.1.1-cp313-cp313-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.13Windows x86-64

native_dumper-0.3.1.1-cp313-cp313-manylinux_2_28_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

native_dumper-0.3.1.1-cp313-cp313-manylinux_2_28_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

native_dumper-0.3.1.1-cp313-cp313-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

native_dumper-0.3.1.1-cp312-cp312-manylinux_2_28_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

native_dumper-0.3.1.1-cp312-cp312-manylinux_2_28_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

native_dumper-0.3.1.1-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

native_dumper-0.3.1.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

native_dumper-0.3.1.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

native_dumper-0.3.1.1-cp311-cp311-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

native_dumper-0.3.1.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

native_dumper-0.3.1.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

native_dumper-0.3.1.1-cp310-cp310-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.1.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.1.1.tar.gz.

File metadata

  • Download URL: native_dumper-0.3.1.1.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for native_dumper-0.3.1.1.tar.gz
Algorithm Hash digest
SHA256 6ad610092356be3372d7c71b5c7bc88530e3596404810afe43b464a53e8a2e23
MD5 b202913ce1972ec5b5154784496bc95d
BLAKE2b-256 aed62a5ed131aacfce475600b5e16c808eea62e8f51f75514551e3e0ff0d0781

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 41acc91780f4f4c7df141b69d7f0a970e746135cc1820375ca1f5f53f8ba411b
MD5 396ddc10f3055273f865e8960a724b67
BLAKE2b-256 68d90ecb4fc1a49d98cd233eb843655bcc823b4ae42e7abbfea6e5f322f0d43b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0b0e2636640f5a6a207adb0941e4fbe2ac5dbb2779f7a276cb7804712cac12b
MD5 c43a1cc19fd44ae943a9a79e8f239136
BLAKE2b-256 71b533a9755650ababa2f2ea2e573ba112532afb69dcc05112207ac56ce2a242

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.1.1-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bc90ea43a9ab0e99e5072cdc8bfb28044f397e71ef1e9d3cd22ed94db21ec611
MD5 a41e69e960bccbe069e2ca4a145c3f65
BLAKE2b-256 94534e673d23151932656cb3ec580cc2e297ccca12abfcf8d3a11e5b0e9f3f3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 875abdd2b67e69014710a76be14d7055306467a9883ba371481d9320c4a4ef58
MD5 0b721d1214882728296bb5d443cafa2a
BLAKE2b-256 30f6aea9dff716cd64cf4b53bed960a49ba677c144c7fc41689ff4175679f24e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 95250842e1f9f58a2fa05f7998de8f68642168e817a42b8773d9438d24761e3a
MD5 143be94279d5c432348b4a493cd5aedc
BLAKE2b-256 d9366c868acc4d6e374a534bd4d0445d2a9beab86634134c3748aa0ccb6b8102

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ade9f6905aeb7a23bca7a84e1564f769f213391f79cd65ea7926844d4ff1d7f4
MD5 d5d95d3c38eb633d71fff499df0571e0
BLAKE2b-256 e1e680d0c74170aeeaefd9d97e67560351239d57b6c519d36cc5b19706a43c85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0c7fc968ed229f4a9f26379420cb1d0ac6592dfe71b2df166e70afe9eea3de05
MD5 0bd8fa472cba1149fabcc87be4f58c21
BLAKE2b-256 abef3e31be87b50c4a0e4b560c72f3d89e2ef691845cd34f84af6eda9655292a

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.1.1-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7de15345a2cc7d74605c298e89736e3d2b07989b4fd23fc52c28e0241c64304d
MD5 a092af070b864c691ecafb14bd80b3b0
BLAKE2b-256 e4c2106a4457c77dc8489e62da93bfb75d0bcc188a7b42304b35657203ad3a06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7930452473ba5fc854472e4146f0a55adab34c4af8ca00e0f76bfb60a8f4becf
MD5 1070f65c4de174ef5a40e88a2fdb1427
BLAKE2b-256 d27fb33d70a8d0171e4c88e11956adcee6b69baf876f41419da741b433be3b23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 cc9e98954cd0c22248846442ccd7d62963410f43b340d2a3942b9595bef660d4
MD5 817739864ec08844a980188cdd0edcfd
BLAKE2b-256 26ea28d5f620ba644de5091853076784012b64e8d59c662071518f9bae652ac0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c93d5a867226ee44afe530d5471b4ecaa544ff6eecae3e5ff548581ad1606bbc
MD5 c80b1e8063feea35c1f77324be4f09c4
BLAKE2b-256 c00197d3b0052f932d4e438630d6aceaed9a9f4caf010d8aae8261da2a0009d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fb4abb57675fee39d47e0bc1c8c85a712977db76cdead1772efaa606b2699bcb
MD5 efa67749fef98d8c06265d7ded2137b4
BLAKE2b-256 bfedd5effe3b5d7ccc192b5aa64e1d80b6c28e3919a67d789ef2bbaacec3b31a

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.1.1-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bdcdc2e03a0b1b9146ef1206902aa1052c8834e72353bc75f8e8f8e205b4ba7a
MD5 9a0aff424e22cd5982f8ff6a4fe2e4ed
BLAKE2b-256 0bbe1adaec6b033491c957f2a1696d69e8371eccf09fd4bfcb0350f8d2cdbc33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0fb2409f732754caf711b8681818b859c0b75a3ceb1d1d95672b140fcc45001a
MD5 f847852ced8fdd23cbdca051911ac169
BLAKE2b-256 9d3e8bf3e310e5397cbe0b0302a3cadb5fd6858eff9a38c0aa57e0bd90b31edc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 279ed04928d21d864da89ce38bbce1e090df4ecc4d604f44d1ab2eeaed8dab43
MD5 42e97445399ed19e755a5c69421ce130
BLAKE2b-256 5c73fd7bad4761dd0f1fac2db195f274e2186e1216287668f773eed4ec8c7a18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9838ee7771f721b5899c0b773b4ff676366fe26ca1ee531ab8059df928c235a6
MD5 0f40d5fa28dd6ae680d219dc569c94b8
BLAKE2b-256 ea62bb4c49396002d6e44a6f81da2f5db9dbce75a5acca6bd4096a676c183057

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cb19bb30ccbe46276321b433e35cadb456180c980429bddc8cf2e9ee4ec66de9
MD5 cf16a8b25fb68669243c11840b83b352
BLAKE2b-256 b73f945ca588963bccbc9b10ed9b1d9b3f85e802ba1348f51ab3d0e6acc1f166

See more details on using hashes here.

File details

Details for the file native_dumper-0.3.1.1-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0151013c83fc25abf02f4d3d762f0425110082786b2374ef76dae441df847b8f
MD5 70ec843b15383699d55850461c37f6ae
BLAKE2b-256 c9fd2f6d40797e2b3cde0d7811b3738cb0fc639d42437b2d5097cb80a40b6999

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4292ce96cc8b8e02af0204368e9fb48c3f36165a527d83a18d733673116e9d6a
MD5 43df07e3da850926fa35827c9d151527
BLAKE2b-256 253ce9c09a855ca6f9f5d895e760ed611b7d103a8d9c66f83c33a4e596b1949d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 fac419792699881e32603a0830257338cb23cc237ee9e0920c5de89465304725
MD5 8d025704fb238f118a06d8a5fa0333d7
BLAKE2b-256 6e28ca6a63f78a3980ea4e433b1fc0810457bd41f83329665885d822dcb40981

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