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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.5.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.5.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3f51c4ab19b1f7a3b52d06ab0db983d67621254bfa172d5c9c63ab22d43f497f
MD5 12ea3ce3db6e3c0932984e42850bb644
BLAKE2b-256 221a4016e29bf94a7578b688a46e6ac3c04958abd0d4b4c33b68049cc48cda3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 95ac711e0d4260889d4d9489dfefab4513151fc62af2a8f11460cdbc6a0ccc85
MD5 adb2b6353965ced4a04bb65b93891dd2
BLAKE2b-256 9275f1bafd8388535c60819dcf04e5e051eb9f7bcf4fe120172d58e3f3dbc05a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1113bdddbe53b20c3737af3c1c622353600e3d16cfcea952274ed491d03e4d88
MD5 bb7c0c039e6b029fa025af9284e92a4a
BLAKE2b-256 926fe36dc48af6212d9095eb9c9ba2b4fbb4fb4bdb2a8a893a7cc40788fdcd6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 723af9b9bb8b0b6fa88a1dc57626800b1a34a62d20bc80e32e918fe9641dcd48
MD5 9ac952f083eb45fe6f459731c97f1f91
BLAKE2b-256 1a5cfda334d17b99ec15164b0bef37ecd51c5e50d83973aa6d8ce69b3d2898a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 03294bab40a5c1d09b3cbce2ed8dd9b02381463600b4afeab112dfb7e72e6ba5
MD5 8077bbe5bdfda685085ab23277695822
BLAKE2b-256 d05b23952fd21f7c372eb94ddf67e371e36099b08a401ee72f033c906770e620

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9fc309c7705290ae1e225f6cae06878bb72a929e370ad4a119683404554ff9d6
MD5 2128122ac2454e63fb307d1bd419b35c
BLAKE2b-256 ea115e650e70b7570853faa3699880fe9a5ef0c7a64d56962fb73ec31620f2b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7362d5446d0300859f6e1f9c8d09c5106d1180b18db5c3e61032d07498475b60
MD5 a709a58c69d14ebcfc7f98676e2f30e3
BLAKE2b-256 740556c7eb6f5f0b0efe3d309e9fe3114b50eb099ffcb69f93d31ac3bae47783

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 748a8c36b42bfb7c0cffbcd88911bedf3861694b7c891a8da45f3506efd937e7
MD5 de1ee10c117b1a624c03bf7c05388bb4
BLAKE2b-256 744d62cefbdf6e44b04e4e6e3989049c069d749c796b02081304196e2c4dcb1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ea11d88183f3d4f10cab84cd9e5eff2b3d703bb5c021f2d6fa0fa0a368546d68
MD5 ceb37f2156fd89c5565144baa4f20491
BLAKE2b-256 66240aacb29d8a190db507643164512eac3a35e710942ea5a4a463320161043c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18f46318715a3d5116008ee285a3bf08f1ee3ca9b62637e91c6d2f3a3f10076e
MD5 28d4cc7fec0941d44a2379777299be73
BLAKE2b-256 67b431d4b7ca337bd28126a2329153db01354164fc15ad7252bb03c4172c3989

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 903b00b3b8aeb4fad17be2bf122bd42716a15022013b72ee1374e2a111577ac5
MD5 7bcfa3b0240b16dd8bfb68eba7f1c65f
BLAKE2b-256 21397d01e2f7d32229e1f22fb039bd5e4a77a4485bfbb47629a606ed784a2f94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2c0b879c1c320682cb7b4618c1406756dfc35893299690a94c1205a2a8ee9bdb
MD5 1486f38cd8fa6450565b18d33e1bf402
BLAKE2b-256 56dd780fffefd3b9e3c5facba05cddf9fed875b4115ce80ffcafd7e210ddd8ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 71030cc8783eab225639deb2b327ac240ac71267d7f9e942853d1848a3e51e57
MD5 ad1e241672525eff839c537fe69cf29b
BLAKE2b-256 b2cbacb45402b53c91ae57758b33e812ffe56e0ad0bc8ca8b1922c80db0dac26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e2f5b757c2364bc82e3e086eeebdd272871efaedce96aebcf3b13f3b7f8a5e5c
MD5 3c9aa3a29f37cd01e68f48489449ae7c
BLAKE2b-256 cc3a715ab4461c92b3831fce87b3b6766d1061fa21d5418a585b9a6a24c3efa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce7a0585e55468b574b6d7724bc1f7162de1dfba3f50f508e4f2d8c0ffe727d1
MD5 5244a3ec7067e32817381c24e5b6b0c8
BLAKE2b-256 cfd82f5008143e6d77ad0826df71c79cb319e604080b3faab2eb7767c460b053

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 40acd02ed33653ffbc8ca978cfb2f282f230d3ded305a0bd6592d87be90b9fe1
MD5 102097c8b37f7e14c540b5b323126444
BLAKE2b-256 f609fb969d83d378713ffc37b921454913cf292a4b3ca934f482f93f509926ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 26d458d598146e33fcffb62183edc2aa57a332b5171933d3830a1ab2362c819d
MD5 031cc246a41043804688664e3304769d
BLAKE2b-256 f21a065c18452c31e212acce1509cc156055226012804d41547c0a0d483e05c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 45338bd4ac7b7e13851fd51403700b7d63208f683d3b3989e56786da145a777b
MD5 af55750099650a1d96a01a1d72310cb1
BLAKE2b-256 696f02b4e38f58281c60d45bef30b02142d42d4c578a416de903035122cd631c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31b68c9ea71f74db077c9402d39bf7a53e0e5dd5ce1105cc5231e514fc0cf314
MD5 da7c69e49bc831bbd21bf96a8187bb7c
BLAKE2b-256 fc3d445074ffc1b37c1a1dfcfc863520d0f9e9cf15b4470871b3560f24ca40b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c8060843d34db5c7567c00dc8580d3a79e8d1f0d86f7e041cfcd41774ccaea67
MD5 c746ed0ed2114cb7904b035c9bba4c33
BLAKE2b-256 3b395018f49a7818d9d45851106d3158d68dbd2357bdf013c32635ebfb607d9f

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