Skip to main content

Library for read and write PGPack format between PostgreSQL and file.

Project description

PGPackDumper

Library for read and write PGPack format between PostgreSQL and file

Examples

Initialization

from pgpack_dumper import (
    CompressionMethod,
    PGConnector,
    PGPackDumper,
)

connector = PGConnector(
    host = <your host>,
    dbname = <your database>,
    user = <your username>,
    password = <your password>,
    port = <your port>,
)

dumper = PGPackDumper(
    connector=connector,
    compression_method=CompressionMethod.ZSTD,  # or CompressionMethod.LZ4 or CompressionMethod.NONE
)

Read dump from PostgreSQL into file

file_name = "test_table.pgpack"
# you need define one of parameter query or table_name
query = "select ..."  # some sql query
table_name = "public.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 = "test_table.pgpack"
# you need define one of parameter table_name
table_name = "public.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 = "public.test_table_write"  # some table for write
table_src = "public.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 = PGConnector(
    host = <host src>,
    dbname = <database src>,
    user = <username src>,
    password = <password src>,
    port = <port src>,
)

dumper_src = PGPackDumper(connector=connector_src)

table_dest = "public.test_table_write"  # some table for write
table_src = "public.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,
)

Get stream object

# you need define one of parameter query or table_name
query = "select ..."  # some sql query
table_name = "public.test_table"  # or some table
reader = dumper.to_reader(query=query, table_name=table_name)
print(reader)
# <PostgreSQL/GreenPlum stream reader>
# ┌─────────────────┬─────────────────┐
# │ Column Name     │ PostgreSQL Type │
# ╞═════════════════╪═════════════════╡
# │ column1         │ date            │
# │-----------------+-----------------│
# │ column2         │ bpchar          │
# │-----------------+-----------------│
# │ column3         │ bpchar          │
# └─────────────────┴─────────────────┘
# Total columns: 3
# Readed rows: 0

StreamReader 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 = "public.test_table"
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 PGPack file format

Get info from my another repository https://github.com/0xMihalich/pgpack

Installation

From pip

pip install pgpack-dumper

From local directory

pip install .

From git

pip install git+https://github.com/0xMihalich/pgpack_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.

pgpack_dumper-0.3.4.5-cp314-cp314-win_amd64.whl (50.5 kB view details)

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.4.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (217.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pgpack_dumper-0.3.4.5-cp314-cp314-macosx_11_0_arm64.whl (52.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.4.5-cp314-cp314-macosx_10_15_x86_64.whl (52.0 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.4.5-cp313-cp313-win_amd64.whl (49.8 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.4.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (219.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pgpack_dumper-0.3.4.5-cp313-cp313-macosx_11_0_arm64.whl (52.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.4.5-cp313-cp313-macosx_10_14_x86_64.whl (51.8 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.3.4.5-cp312-cp312-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.4.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (231.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pgpack_dumper-0.3.4.5-cp312-cp312-macosx_11_0_arm64.whl (53.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.4.5-cp312-cp312-macosx_10_14_x86_64.whl (52.4 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.3.4.5-cp311-cp311-win_amd64.whl (49.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.4.5-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (222.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pgpack_dumper-0.3.4.5-cp311-cp311-macosx_11_0_arm64.whl (53.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.4.5-cp311-cp311-macosx_10_14_x86_64.whl (52.4 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.3.4.5-cp310-cp310-win_amd64.whl (49.8 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.4.5-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (208.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pgpack_dumper-0.3.4.5-cp310-cp310-macosx_11_0_arm64.whl (53.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.4.5-cp310-cp310-macosx_10_14_x86_64.whl (52.5 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

Details for the file pgpack_dumper-0.3.4.5-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1c1ac6e07a6a6c96acb89c8b4572e37ccc417614d4726644923b5a25b7a9adc0
MD5 1095fd572d19cf84c74f3de35e968531
BLAKE2b-256 fb33ce9ca87646d6fe93ba1c280bcdec46fa7ff413e7ef740ee333fcfa193eed

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 7dc5a591b6d6eb78d8c831ef6193d8f1d5f8589164d47d413f920cad856ab38b
MD5 bb2b77f333d98acfd1849beb187f4271
BLAKE2b-256 0dbebe9ffdba4820ef4444149685876b1400eee00f22888929992a68c4ef3765

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed2d5f9b4ad8b6a4fafb016e931e081a78d57efdb5cc6a5b86fff161266624f7
MD5 4160daab0d688a5f7fed6be645d5256e
BLAKE2b-256 b56c2b23f19acc6520a5adc6503e1410974ceb593081769be55aef1cfd2124b7

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ee3563f8ff89b9329f6606e412c03dceee4530646969b54ae2d2de99d5bcd2cc
MD5 23b978b45136e3a541822b7f7e1263d2
BLAKE2b-256 e24578a668659fbda9966eafc59c33bddc4a43e661d123986319744a025fd448

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 84b759f07458bc41494ce5d86946719f28ab79ae2123e584d77c132fe783f619
MD5 7c712d49590f87456d7edd92b79608c6
BLAKE2b-256 51f16bb6444e772f18b1bd1bd9bcc769891940f0bc3ddfa12a0a11dd41847ada

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 750e595d0134fe23aec8b48f0009fa6f25b01b231a780701f9b664ce33a449e7
MD5 0538f3d06ef379fa636722f3934ec5b7
BLAKE2b-256 955899c569b516c055044f7f9d3c5db074738eacbc5d92d76fa0ecdab94e9f1f

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e45d9d95cf5ecb4da0ae1f9db222ca482c1e7780014b42b8bd7486362329041
MD5 2ee8a8e0d9d4666b9a1561d0da41ebdb
BLAKE2b-256 e04f9956cf60fad0531fd21295a9805b987c7276be23aa8901f2ad1bdf11b177

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp313-cp313-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ad9c03ae646250daa605f2996dc134e05d62a92b9ba7501d6fad2251b00226ed
MD5 c64b161f14c2f44a077deee89becad47
BLAKE2b-256 d19dd38d4b6bc6bc194307611eb7795c99768cade886b54b438cf486d9b27779

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 16181886283113373880759fc101d0192c188648c6dc71d999bb49e55a152fce
MD5 2cb26ec44c878f640be145b8554d1a79
BLAKE2b-256 1f97f46e3c23671ef03e96131732e313e99a1e00e884bd323b6470cf6d5686e5

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6bdacad8a5c3689cd1b5886073e4621afd67db0b296f47665f03828cf33d9e9c
MD5 39b411c95f3aecba63d6c6450e832e92
BLAKE2b-256 f368c27d6e74df87a3524b7a4171ab92036e3b55d3891177fd0195668c460c2f

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5aaf4d7a52d90e1bd29106d364c59a17ae8279b9939f6017791b6e7aa305fa20
MD5 b6adf823a3df08cf3943218bb17599ee
BLAKE2b-256 7154e30a7d619a7038fd0c00e3bf36b4844a82ab10c7c701e3684bd138d06f06

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp312-cp312-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 7794f4922acaf54a8a15c573b00d9d28852aedf88c02396bc81fd5d5d7ceaf19
MD5 64f22364c290ccdaaa476db3b9fba554
BLAKE2b-256 b81721b76292eb5da1f83593aa245b56859ff6a603fa5a00776a22fff2981375

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ae8efdde19db9ea0f69c60a601beb076b14f0a8d7326a4a7e1e28be3489c7284
MD5 1c906ad79083c3b9585fdcd3d6150a25
BLAKE2b-256 e9f6a88bfe1ad196507b0d94e30132629358e1b6215b02e06105e9ece4868028

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e880baf998aff1500a119c23d48ccf04bc9299a0092d308c2cf5e6f372d1f5be
MD5 ffa3148b1868b9e9c7543b2998316fd6
BLAKE2b-256 262ced345cbf021e869384430dc342620ce501401d8a98554ba1a9e7614cf19a

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e924977222043401e93c28b1ec460af57615f44e8b2879cb033f7715fe0c590d
MD5 eae15ac55218e0d79e3f0e91ab678b5f
BLAKE2b-256 3c3e503f727da850a6a21ecb8195ab021c9645626cd1a4872e1f54bb2384a324

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 91930d8f1ccf3dc61b6851f9dde47ae80c7b504abfb60817acdf5cce71cf18e0
MD5 cae27e904e4727b5199eedf1862dba45
BLAKE2b-256 66c49e74d16f02a9955e2943f529a30e41085e399ee504e382867d4e3bf76f95

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 26f9acf8404032e3afea15675df6f09017ee40b8576a0a26602e9bb5bf61dfd3
MD5 fbb3c78749afd834f9ec44569081bb6b
BLAKE2b-256 7ba81dd930fa310f1bbbff68a63a1bd90c8b03dbe291e633f70dc92f6480f3da

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ffb122181224ded32675a9b7293966e19e9d1eb4cb07537c15267bd07916b6e0
MD5 e05c82f371d68d2469cce9d070e6aa74
BLAKE2b-256 74855c03fb6b559ce5c4fb11652b68a0cd7d458582da0edae887c8fac493d206

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc9c51b287f83d1efd11d4fdd9f961931fd56680c9064fd15fe2ba10d8b82845
MD5 4ee52590986b72945723879583f4fc7c
BLAKE2b-256 ffaed64f8cc092d38b5835a8e38cd5dcc4d706dfc91ce7a8e00d9c51eaa88959

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.5-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.5-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 98e75fa78a34e877dd82aab61c6f97d0f5a8d09e04bcb0439d056cb258aa7b6f
MD5 4366df65e39aa6a0181a93d02849d56a
BLAKE2b-256 c86ef176559c0ac8539030ce8acdb3112c9702a9774075411c71a0b60ffe31f8

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