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.7-cp314-cp314-win_amd64.whl (50.5 kB view details)

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.4.7-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.7-cp314-cp314-macosx_11_0_arm64.whl (53.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.4.7-cp314-cp314-macosx_10_15_x86_64.whl (52.1 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

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

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.4.7-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.7-cp313-cp313-macosx_11_0_arm64.whl (52.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.4.7-cp313-cp313-macosx_10_14_x86_64.whl (51.9 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

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

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.4.7-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.7-cp312-cp312-macosx_11_0_arm64.whl (53.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.4.7-cp312-cp312-macosx_10_14_x86_64.whl (52.5 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

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

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.4.7-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.7-cp311-cp311-macosx_11_0_arm64.whl (53.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.4.7-cp311-cp311-macosx_10_14_x86_64.whl (52.5 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.3.4.7-cp310-cp310-win_amd64.whl (49.9 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.4.7-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (208.7 kB view details)

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

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

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.4.7-cp310-cp310-macosx_10_14_x86_64.whl (52.6 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 f3b02940d8a42108554ec4d3735d976dd5c8c8b9efd5aa2d2b19f9698814e851
MD5 18fe309f370256f6ea8a3e39586fc4bd
BLAKE2b-256 47d6b8a1d6a6a5daf36975c5693fc7366e8b9898c432aef04c9902ff83a6730a

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.7-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.7-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 aba6930673e2b292bcd0ef6479b58020d412bec192bb4ea229e5c1217fc88a01
MD5 29ea7f52395e688e2b8198094743629c
BLAKE2b-256 bbcac31d4da519ee09e3e5c223803ed6a359cd61c16e8a2fcba8029a920d6a5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b2b9c7ca3c9e281a4c448fc96002ea26632a0d46a94a627b496b1b48302aabe7
MD5 f9089d786a300e0fb594a218504f1693
BLAKE2b-256 4184c0afd7ef3e238535098125cea604914166bf6954493ad1c062bea8bae814

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7315f68bd8197d5aacd84928f829d8c433cd1ce564ec842b6f63d51b3012ea2d
MD5 c07f3e3206c90b55f697a213eb881c3e
BLAKE2b-256 dc1f40b01c7d6cd1a2e18d00141c8796f2a461cb46285459ccf47c90df31474f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 14af788059c44859c091e792c4f2bed4781e8a9a66a51a563af6eb3221fa74ab
MD5 15104c588be4fc0a99e8087593bd7199
BLAKE2b-256 3c2a62b6202d6f079afad68ca386943a47c2e1a281ec0562cd337b5a81c543b9

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.7-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.7-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9419163d1dd8790c0b190a758b9ab1d509cb4dd8039e674cd2e181bd40538887
MD5 89f5c0c4c6d4ce8adb34b967be5458b8
BLAKE2b-256 2e61219950a561c5886ec384d49608957f28852e0208bf2a79280be6139784a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f3c1d1b07277df6562cca5db90e575d8cbbf8503591e5381232ad0ff817dbe7
MD5 198e1b3dc4797005b8ec45318c87f0ba
BLAKE2b-256 c1a9c911801d09de6e3221db845b258b313f88c8d1a9713cd51b1700983edb8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 23efe77e34afacbe1ebd71921199d5105486f6b9a05ad50ad8b9c6b8cbee0291
MD5 787cb6a5f33faf3d5f2ef74b81a07a07
BLAKE2b-256 2dbced10fca0ca1cca5b2ef4b83a8178b4e474428fa910f117f082ae13619b39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2a6217a480b211d249c09b8c14e1e9f3368b750130526f83a2d031352a670112
MD5 1bb43cc1d3581eaf5340f164e8a2c76d
BLAKE2b-256 7e8fbc8ea93f5aa6b24377c87265c156177d41af930159ce6a6ff6e38003e1e3

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.7-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.7-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0e13c218a589403ad23c356dfab3ea574cb4bc059cf4fa44f63e7d7dbf3c12f9
MD5 ba036202f3e38f0b1ebbdc97ae14e357
BLAKE2b-256 5e7815c8f40f94b1cd616c759915d8636b60ca8ae9a74b0a3fc23fcc9abf45b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 521fe87dce1c468104f3b52691628cf4e946a0262dbf86288372abab82d776df
MD5 961555855cdec3fd1a284b44b2517366
BLAKE2b-256 c644280564d43d6505663bd2e75e1e0a31c957c5ef39aaf9468403cd9e22b8d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 79636e68abfc1aad3d1177f707b1bd3e3b6261e62ea8e30380ac46913bb4ed4e
MD5 50d775ba29265a157818a809081e5a2e
BLAKE2b-256 f22b9ce382480f3749ece70f753fb8f5f25b17fb0eb756e2935d849b80b852cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3c58433861371e3fa7f88ac7b86b31539794c5a4e9326c2b4068b0c5c1f34460
MD5 b74c7314baf60f8ade398a8d78670275
BLAKE2b-256 e1f4c1c9ba3c087f25fb9c289ce1315b4ca7aaff98017332bc5fc01e9e828098

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.7-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.7-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9be3909c3e5ff7a4d3efb00210b0f4c7587f42f3d5907d96e14058af6c60bdab
MD5 edceb6a14dfe2acf7ab731eee366f683
BLAKE2b-256 acb7eaaa4ddb63612b71b7990fd4df31a042698b2d4cb33cbe9ef67f3be00c36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8c08d53ccaeda8385c36f89ece3a6602ccddd5e47cc2a19e0c609743104fe6b
MD5 96ff9915c88fb6a04d9730a3f3b10c6f
BLAKE2b-256 6340d820e385873965e7490fc71e1b0466bb65d99fee051dbf25b037ebc37b55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8f7a5e1fd1f74073da0e65d97f95a7f266347ffa006b9cf8bf254068c18f9d5b
MD5 55a6025b9f0ed5d1bc0c137919f817cf
BLAKE2b-256 d93e395bec74341932579b759c7d856fbf89afc8ab511c06db6297eb0acdeb08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 71776b5be6ae0de4826bbb5c81905f3cd49826f51168c744816ade9802656fec
MD5 afcb8bc012a0007efab175009f552073
BLAKE2b-256 5140739f1b2985f10b24b6d530e78eabafd95119a860e07c5e30ec63d14fdf4e

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.7-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.7-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 b11910e5a2f49dcbf0569234b578e27e500b11b7b8c98917dad364ce68da1898
MD5 6e0892666e5aa3bc91c40781bc874c7c
BLAKE2b-256 716e8b6e30ca2c3d9ce1b9d7724d8aec200880609bde238a8264fc83f4c11c08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a2677082b7d2455708a31f016c078ae07c9dcf0ec42149de24af2a51c12a442
MD5 01ee0cb5c0b2d51a941cb8ccd4d9187a
BLAKE2b-256 83df0ebb976c3e9738f0966e8d99c264ba18613755b6f5048ac2a6747591d2e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.7-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 27c33c7ae4e634a5f3d07a57b24a02a0bbae229594204e3a585b2e3a4fd8097d
MD5 c8fbde3b791db3485e40651fb9e64192
BLAKE2b-256 39be93f6b8d237977094b87c919495df94b6c82be637aaa999d31545c3a4a084

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