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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.1.2-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.2.tar.gz.

File metadata

  • Download URL: native_dumper-0.3.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 cad9ea6a2e84204a465c023759a7f7a29c03570e1b978bfa332dc950a62fa0d4
MD5 91f276d66ccb575f646f8a60b9f7910e
BLAKE2b-256 89aaa72eea12d8120d986dc5ed203a2ff0267a2fe71abb13ded51e02a16e8066

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7d74a8db674eada58bba24c6b4544137886311bb65ac5a44544d2479b8398bf9
MD5 61ae138d42b0c90212018f57bdf88912
BLAKE2b-256 4ad190513e1ce74786e64d0e735641f8785214e522b339117c75a875c34db34f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f11284b4197ffdf214055b757bfcc60d1c68c578583d51fafa654c5c46f10599
MD5 a15c2742dc5bad8443c6ed72550d25a2
BLAKE2b-256 136bfd93520e5046ce3c709357eedc0fb72de8562d3174f54dc22f1e66fb5400

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7c2f33d6f72f455a5c74a07de1ce5cf4b3c59f701f5737527d8f3fc28d91a6ad
MD5 6ee64b57941e566e2d17e35b9a0d48fa
BLAKE2b-256 c237c2d3ff28fc525ade597155b64fecba33e7f9701edfd230649179811aef6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f467f019b2dde1266d907673ee7b6e600d2d905141957f0bf0af323dff4f3723
MD5 b61ccde14d90864de664e1393bf00526
BLAKE2b-256 2ac71cc743083f95627bee87b9c0825edc54d4bab0af503f92aad93e9028069c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 03d9ab992c9130edd6e0443a34d674eb821c30a7155f324ed5acecc201949e7b
MD5 a7ef371f2c566655c4600c9f212016b1
BLAKE2b-256 5934be99e91b60f95a30dab924e567a0606d25464bd8d5258287e027ec68e413

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 373992b04ed89c6276035c67be168f8d1be405cd534b40a27fec27035b835bc9
MD5 0ed95649ecb39edcf7f27d150646ceff
BLAKE2b-256 4de470d6231241eb20d1453bb8a851a3fd85846aab31c2c9eec32dd2ce5ed735

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f10ee678f42ee24e307beedd1e11cf3606be962392e0fd46b978bd22630dac94
MD5 8dbc9d305d05e0fd022fd989d67e5fcc
BLAKE2b-256 6bf428a96132b5cce8a3447e744ceedf8611414b297d4f8ceabf8a8501ff65a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1b666533ccf32655495875e23fb3631094954336be2c16b397bd61cffd45c525
MD5 e54d9840f31154c03352b059eca799f4
BLAKE2b-256 e843feda4b2f1ab5f16db67ec97002caf8c1e17d2a59d8ae7bb357b96067fe05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4093ff0777e167414999fcd1cf2ad585014628ee59607d3c4c3f3e8cc5c6144a
MD5 3133a54d65663764cfa6ad3710c38cda
BLAKE2b-256 8544dc5447db25c59b1989551ba7d9da11b9c09a630b781a65e4094ea9a50b4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 05b139b4f3eb0c89e863ea15ba549826c62213a921b9f78aaa786f2f158329fa
MD5 6bda80c22d44c82b6589e51ab57be289
BLAKE2b-256 3a4af3c738015ee90938bb1548ca14d7cd68c50a5390fc468488a2ddbe2f9573

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a90c9d2e97879cd3ead66e5a2ab497706f70c0c20a04db0aa693fcf126da76fe
MD5 a80b138838eeb47337ac3c4fc5e67655
BLAKE2b-256 885eb78c81a17ab0b63f192c0fc54dc665b0a791d29051243e4cb38a36767f41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 89e58af2c8f83a8ba26fbfbc3ef23cf1271ce8460f6fe7a6964941160337b558
MD5 fb2a3581091114b5da085e7a86eadca7
BLAKE2b-256 d5f7e571cf5d03966a13253dac2562d4072bcc9179d9ffc11758445c1ea59be0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0ad26508e32493562e7cd8c65066702c1523b8a9a0a884414678b47aadeebff4
MD5 0ee9db985223833e24d6df8ffdfab5b1
BLAKE2b-256 22971a59121b3e9deb3b7cd5f75ae9367b7d87a54d79794a33c31ae19645fcaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c747fbc40888da575f609f01db3fa2c9577b6e5f5b9e07310c9a1563fea8ab22
MD5 42eeb3912be06b77903a2db8ef092074
BLAKE2b-256 15b5db75fab8a1e95402c8558c25a27a9fc9bb7a934b14a91c38a1c44d78b910

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f7e4e2b192d92b4fe44a5ff6a75a65fcf2fb129889d3e5d9b57b1cfaec50e5a7
MD5 d2be634cf6c321025197576eeff62d7a
BLAKE2b-256 599a50142acc0cb4f1c1f0d251ca87a0a665814a4346347c9b759442ce2e4584

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bb57be31da7b1afbec618b99830452e82f86a8f78ae07b8b5fc351def810f82f
MD5 3077841bf19843691f692c563e383a40
BLAKE2b-256 cddddbfce11cc6a98df2b60758876d616474c67bd93301f4211c015befe146cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c15cf8fc1c7196405f0789fd13257ac755f5ad2c81fd2b15ca09268ebc2d313f
MD5 881a0c354f13efbbccc1505e771d1233
BLAKE2b-256 ab44e4c9579b4ccff7c14c61ace09babfd3fa4f68262e90ef50a00d0d04b1317

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6cc6bc817207ad2a3f34d23e535ea5d883d78a9bed6274b42f1165bdea7cbadf
MD5 b9f7187d0b37c1f72845edb9a28d04a4
BLAKE2b-256 cfd7d3bd8f0a3eff03a7882dfab7976755cb44b12fe802389d6cc2749dd26a3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23f15bb1509c125cb46410c05e6192c24a55ec21d683ea93b0eadb3fdbfb88a5
MD5 f4b007b614298fe8f7ed94a06872ffc2
BLAKE2b-256 60f46605b4767eda660501bedc5e590e835440565f32a42752a2e95da2b716dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.1.2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 873716ed58499a558d34ad72a078134c952cf800093e30ab61335fa2684d4106
MD5 ab69720833073680afed8064d7c91459
BLAKE2b-256 c216b00826e478743d9176e30eab814468639f764ea61510b04e4bc3ccfc4b61

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