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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

native_dumper-0.3.5.3-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.3-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 493ab3f547729c9630418975b151094c8ad2c2c1aa87674e357071b6484988f6
MD5 cb07224416f83c3a3444389d4995e4f2
BLAKE2b-256 e12bf3bddfbb2ed0afe608cf38d6c0b531dd1f49e5605792d8076957e3e1797f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c0abb11f4ffc920358081cfd3fb5152dfd7392414862b4e42ef494d14e503a44
MD5 e2566c0f773c334ab3097ed047e1e0d0
BLAKE2b-256 ec1fcbf47046ed552a8b8fc24144c374baeb0221e4cc25fd4e022ad7ad4d5daa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7559459d4bfe03dc8de4e2965da1fc85c1cd45e398360edb1f202bf919789f57
MD5 470adc095a7945282a7890cf565e2de7
BLAKE2b-256 7a4052593a008c2d6177004f84b1cecedcffed9bf50101ef268344c0a39e92b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a7a5c7f05b24a37d0fe5c0011b53841991c6045219ba8a36095798b45096284e
MD5 a6c386124946216e0231062de4ffed30
BLAKE2b-256 9d2e2eb255bfa9010b5f79edf36e032d65a1bba6f547754e05b5d989485d0a51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 969b0eca581ce19ffe7788739d364f444dd903e5eb51ba07366933229254ed94
MD5 b9fa3668820007df95d2e5228a42548f
BLAKE2b-256 93f16c7fe6247beba963c6b1bdf3d88ba0c77903d255f037f58a53d778f8147c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c868ddeda8f355db0a1a7107b085124b1ceeb8928d109583d23183989534ffe
MD5 ea6cd7a3d567618cda87599e7ca0ec61
BLAKE2b-256 f38c632d0bff13391da6933288dd7b644f841599bf5d869bd1fd6267b256b79e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a7cddf66b799a22b1700ec36079df327cf08c1ee04808ec71b9aa8340b276093
MD5 06bab1809a393eae15ff43b024f9a197
BLAKE2b-256 67bc808d067b733a616680651615c4342e7981061d4a96c942652e8954588cd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8378283b533d1e800ae75461b824c41259eb07c1f3a6114f0386602a50b13a10
MD5 3f86748967ea763cb98e5ba9a70ec7a3
BLAKE2b-256 0557b77f7f27c24b56db07b8b71fc25e9c1aee393c824bb54236606c1260f23e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 18d0214e4f22f9bc67b04965815783c5864de0f6ddefed257ff3525f3c93a51b
MD5 bce693b8c297b9e4de41ba735efed1f5
BLAKE2b-256 d6c77b6be99ae7ce1984194e234f255d9df628c9aa3f2471e1a192a9e9fcb830

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d79a9b623a75d09f2f529dbec0e0048f3751a73637452d16a4a0d398cef627d8
MD5 037bf52b6719d9b1f7243d1caa0e32b0
BLAKE2b-256 7831a3109f4e9a6ea86e90aebf2b6de3dba4d9c38fbfdd735a9748824363dcc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7591c0d0aa83780b7f0bb73d98e2a476ea08a64f893c0fe968c5c65ffb5ead7f
MD5 b4e4ed14864a00692ee09f45f074b36f
BLAKE2b-256 ad943892b1a8bb3d6fcd29f0b8d78620b4db227a6a407c4720167c8d5a506baa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a043007a0d097e301d34eb110178c5c82f01b4f9eda29117093eb4ed2fbded30
MD5 da442669312549e2159bad9a2e1080b7
BLAKE2b-256 45eda321be01b9cf1c1823e14c8925ab2b79dcc9074c114293ed488d26c4b869

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 92c41cf1776f8153a3012fdd1414c4687a63ee183d3453946115259e973c8b9e
MD5 d53eab098f7d0798a3c3ef81b3d59e2e
BLAKE2b-256 66f4bb6c8684ac8c40cf8ea7f36bf5a231f07adf5fb60f5eeb49d0d88ff8f700

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 21903e9a15a28f88aeb88163761a6fd65920b98702bc508fd206a04dc8761fff
MD5 f25b3fa522b5a970fd9379d315032e06
BLAKE2b-256 fdee7f1c8016ff1f93b2e8bbcba5e641c86d046254bbed98f84db2052c986c11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5bfe652da196a59cc4942b761ceafc79cd568938dc1269caa35142d63b6d5ab
MD5 54015a041e68aee28c5b6f0adb1c8e21
BLAKE2b-256 05d2f6fa34766d50dc69c69ff4000d8caa04115e7a00ae9030569a30d5c5eea8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9f7ff5998145bde08ed9d2886e5915ac99044fccf84d5e61b1d2856e622c640c
MD5 842f0e4bfbc7ab53420f30e4a7d91066
BLAKE2b-256 6ca0fde1493aa870fc37ec659effc0930e6a0cedb208776aa9106aa6de016ac2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7dd7b8a403dcd36e2c1c6f75bde7e5b010412b2f3a115af05a66caaa3cd0a203
MD5 0980247870a6ff116177be9e4fcd27fa
BLAKE2b-256 76782862cce8c9ca325780b9ed347566e3a9e95d755f940e197e7db2020784a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d2cff82cb8b6f45fad7dd6329554b76426886b897ea3af35386807bd23a32539
MD5 8fec8f1f2f989358c389347d6c8ecbaa
BLAKE2b-256 638d500c1cab688eaf37629c0af5e35cbac67bac52b191a921dab6d6d376ebde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00d1744ee0c7c343137c8e17c06f138920c5d6df6f231cb31773b84c39d4c2d1
MD5 ef7a8e412c4ba66ba4f5bd9487eef2d6
BLAKE2b-256 52ab0610c08eaed264f088d67a1f778318151c6c0f68a64b3c85da5dccb6e3be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for native_dumper-0.3.5.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 30a900eb8af3d21ff6897b02973b6ca897ee2f8b008160a66a1730f02b234a35
MD5 39aa03eb9cf47a4c7d63cfff0938126b
BLAKE2b-256 5372f52fe1a2de19fc15e6c15a2df1067fcce6f7b93a1ffefabe59fa35a88c85

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