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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.4.6-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.6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2b173c835cb066a07fe30d3aabc9746ccbcbbce59e52695d89bde4ddf8b2b13b
MD5 3a173a9672aee05cc90a0712a1405e07
BLAKE2b-256 4d99b60f459432b768f97b2c6b22ac05e39255b73d8a3fa95fd0a270d430888e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f008072e88ac3d061bdde1edd0177abc5baea8274bb119764775ef7792206b7b
MD5 ccac09caad9f19fb94825e0a28fb6eda
BLAKE2b-256 82b143afc645c4abe38ace56bba63691c0e04cb2b22f377d72369140fdc02245

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9503abe93d08b019bf117f1081ded05e830ba834991fab2464073f95631c8c4
MD5 d918e57d1503ab0a16f23ebeff458253
BLAKE2b-256 75905ce5fa43340c207edf26b6b2ed200b7e2901dc9e7457ba8aabfda2550fae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 7db164e4097330bb8f6822e169d05b141d97a222bbc06b56614e1a9d4cf22b58
MD5 ec5eb1f76cc920d9a6d847b3f2b4b685
BLAKE2b-256 72aa30230f99f6b2011ebe49a33a0748fb6be01e83ee02ddf0c5b2a157465a30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 131783ca7bd5c9154869804cda8db046f342f15820ea588296e02472b144af1d
MD5 febb48b643085a4d847dc6404cb604bc
BLAKE2b-256 a7d2df35ce7d88b4857ddc2e2e12f2eb0fa4f445ab3b286d27e9b63f569966a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5b2090b04f690636434451b985633b3cb63955c8ed41a6ac25ad7e58355cd48d
MD5 7f0db45e28ce83453a79fcc73575675d
BLAKE2b-256 f960b2f38e8a00f9499093737411ed3d98303ead1759d13e4b0e8269e74312a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ab8ffed02058b9186783bf589471bb0f29e3ebdb7d2d77c51042413871f3637
MD5 b9215e3da00ac54a0d03c8e27df6510f
BLAKE2b-256 6769964634d3f31a96016be2a95694e2180fb8ab8879fe8591ea48918f70e182

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 29b277c103e90103730cbe32f25db009b5f477c3b0a1856db0ec9da452986513
MD5 db42449201478acaa4eb048866c11e74
BLAKE2b-256 a623ac9d3c654fca2f625708e500479ab1f2bd4aa02f2e0ffc53aee9f997bd36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 751cbc4c1060599868629067816f7bd3e552ffd78c5e592a1257331f5539675c
MD5 8f1196b51103ec2884a3084ebbfc16cc
BLAKE2b-256 f8a59bfcc87f81ae486aabd80027d7ef825c2acafec41236c903a66f433c1b4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f4b665824789610ee5716d4f0b664261f7a63e423026f51e4dac1f768de95c48
MD5 129a2402686c1650d97aedbe6312592e
BLAKE2b-256 d349d1186b0eb989d2dfecea50dc8af1ff89380a42de76b022b0b2a6ff4e964b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1e4905de056f45fa23218f3a0893cbeb0551fa7d4944c6220f4bd4fccbff751
MD5 c81f030b26426c322658f95928eccad9
BLAKE2b-256 22d4347823e0286e2f900703158b7a234c1d8f95d7b466876045e97e17655dbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.4.6-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 80351a1f1207adee56c7810c0e5a1e81fef421e82c95d258af39713ea36fda54
MD5 5dd99ed2ba8614e31ece59714bb230fc
BLAKE2b-256 f5f44b71e2d1d68f4ee2ed9077a546c39a93bffe8bf25c6099c55fe7ba9ed36f

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