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 PostgreSQL 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 PostgreSQL
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 PostgreSQL into PostgreSQL
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,
)
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
Release history Release notifications | RSS feed
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.0.1.0.tar.gz
(7.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file native_dumper-0.0.1.0.tar.gz.
File metadata
- Download URL: native_dumper-0.0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dba79b078b673c8593c5b52bf5fb475faba4e1246d2af3e5d9f8d3cd242aab7
|
|
| MD5 |
6710870507b0df6d06ae551961374a59
|
|
| BLAKE2b-256 |
91fb069c2adc24552eabaa128ef7bcd1be668d689e197a0230dbab420ed46280
|
File details
Details for the file native_dumper-0.0.1.0-py3-none-any.whl.
File metadata
- Download URL: native_dumper-0.0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e67c0217b234ed3e935cb0677b0712cf8520cf89c8d50778271aee2acb8efb4
|
|
| MD5 |
27a64743956b8e1385c87a523d1ac0d3
|
|
| BLAKE2b-256 |
ae67bdebfbe8eaf6ba7e9f9253d874ea2dceda2f68fde7038c733444fa6a9f45
|