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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.4.3-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.3-cp314-cp314-macosx_11_0_arm64.whl (52.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.4.3-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.3-cp313-cp313-win_amd64.whl (49.8 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.4.3-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.3-cp313-cp313-macosx_11_0_arm64.whl (52.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.4.3-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.3-cp312-cp312-win_amd64.whl (49.9 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.4.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (231.7 kB view details)

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

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

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.4.3-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.3-cp311-cp311-win_amd64.whl (49.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.4.3-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (222.5 kB view details)

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

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

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.4.3-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.3-cp310-cp310-win_amd64.whl (49.8 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.4.3-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.3-cp310-cp310-macosx_11_0_arm64.whl (53.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.4.3-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.3-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0b2a24b9c00bef7006cc0dab5b7feee3816f134f3213900ed6fea9abd41e7f68
MD5 5acbb82f6f6fdc650062c2650912e4ab
BLAKE2b-256 99d9e381b43be02a5528d4bbc21c7aa5cfb7a273473f3bba5f43c8f3773d3b3a

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.3-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.3-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0e2d8955f6ed70cb0dde5a39a2129d3e3573531f2dde6f18176cd5cbca5c648e
MD5 c799b60b2482011eaf2a08fdf40affdb
BLAKE2b-256 92cb5185aad725bb3a56619e9ff90a7bdca15691d63966582500f57f3ec200e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edec31b523298bcc649e1037bb114e2d881e9d171ce781c3f86fade3bbdf4631
MD5 5fc637877a36b7635193eb469ed22715
BLAKE2b-256 1c8913b27c4ab46df0d2effc0ffad51124dbd1a69e2db24bb548eebf027a6de7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 438d563c1606c3b08fccd8cad93e431666f31f306824d7b09b8114b5e92cdad1
MD5 5cc78ca8a8de619dd582a49421222b41
BLAKE2b-256 f4b990b64db131e79843a449580e2f8f89f7214d21595ede038bd311b9854342

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 68007fa3e196c6236abc8415d8432c585c56e5e6b79ad7980e2cf7ffc0db2baf
MD5 34c4195fb44985a240dcb2dba2042cae
BLAKE2b-256 01cf95dd4b7d1682010d0581ec3209fa36d660fff2abab64e06bcf883cf530d3

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.3-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.3-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c070caf2ae017b4e446bc5e6700eaee8bc28d3b26e988b9f8778f928562437b0
MD5 4564c3cb2a45f719715786f5f2091bd0
BLAKE2b-256 04ea5fbd3724ddf27780403bb7baa0421c9773cc8ae1df9b51e3df3742ef55e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b2d43800ac16ac9607f4ba2400b5e1cc4171b415933d3d4b08a254019a4ac02a
MD5 6b5b78a418a07ee604cdc1ded06a0467
BLAKE2b-256 556d75cf57efa5f7fc49cf8d82bc1d7a8124f4eaf07647f8fcb0dd9380ddbd68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f960abda1fa859e7221624b0f135893743fc299f0681048dbbde5f8084f36659
MD5 cd1197f267e3d4b0ed282d2385814df3
BLAKE2b-256 dd407fba4ce1108448b7192244500eb3d4872086fa0659085253fbbd09b732ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2bb9434b28fc1ff6c702d9ff61b4ce0ef796e6424d53977910dffbc151a3658b
MD5 aaadeecdeacd9729a626d7865ff62a5b
BLAKE2b-256 587a4b119a24d465c851c726c46e8ef41a66e46af1fa9ddaa4b717acae38e4eb

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.3-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.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 99d36b70c178196b9f0e4a0923408a1797f5cb54cfcb22251b918b95ca42a609
MD5 70b530fbec0d20ebd46b16e4bc200e4c
BLAKE2b-256 a99e50476f0c1c2e95e3821b902638c63f6694af5de274fbc4f5d9f6c18cabf4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25df5efeb4be5d3c246eea31ab93aef6975cf570da50b3e7f50534406b53fc5b
MD5 9bfe4315aee5eacfd9e594c1a9762b5c
BLAKE2b-256 5af0482952b034d831bb46be34a17697035568541178142e4784056731128d71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9066f1520f314acf5f46189ae5d567085fe2469ba4876fe682bc2f60b5194b26
MD5 4f5f06f0650e56b58dcc8de9197a3e42
BLAKE2b-256 889c0b68bac52b6e246cb765a0ba46ca716df4c17dfee9bff8c762c24404b15d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 735be9a0694c00eb01aa7828400b616f2191d14c01ae13ec3d998574a3193a79
MD5 513d1acec417b77d2b4d63c3e4aec1de
BLAKE2b-256 b913d117d3a5d3da774af9011e93be5ee6a589c0bb953534aa0745ab713bdf3f

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.3-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.3-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9a8af7cd03599b52ad69d275f5383ae0c445471a718a623ceddee68d9d7a6cbf
MD5 50831dad6c4c4b2a28ab35e48d2cc6d4
BLAKE2b-256 ed48d8fe9833ab1d32cfffc546f30dd6b1b3e699f353c080eeacee760d70ad7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b26791d47e6ce70f07d68683d6678dfd97d069ac8551e7e2ac40ed9f3a963cf
MD5 b7ab0dd6e045cb879bf65e1e1add2940
BLAKE2b-256 54d8152963c4c3ce39bb1d4e7e78a70f667d17b2e71e4da11b0659910cd1b8b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a6883cb841314e031fdc950953b05c410cdd4ddb86e4035c57eb5c3fbfdee55e
MD5 d30a75838f417487bfd9e4616a902ec1
BLAKE2b-256 45790ac467759ae3d799d20c859ad84948a82dd07cc9c2d3e69d5891fee645c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6df84c1407067ea37db7b536d735c6928d13dbc706e859c1753e238fa833383f
MD5 a02dff8a4f9732ad23fed2b4ed3e279e
BLAKE2b-256 d2238cb7c0d7592ae9633f930c81af0194789d89b7cdad9bb82303f98670827e

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.3-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.3-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 fe3c25ad42b9fb5996747810d2e4dddb841401f967e70fb97e3ca2726f2f6330
MD5 18e4fd49d0bece5b8b93a1c58cf75ed3
BLAKE2b-256 4e3c9f762601e5b6d89326b3593f954ea9523498d9f48e75deb12cbc94110e6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c0253713594865be79151d1e8fac4c207858828c1c26f0286266c27c7ed227b0
MD5 26a889e9f2ce30e7a1f41bc3bd505e28
BLAKE2b-256 d9f809b7e70e8ca3e8eee510e17c11328a397980b281d0cb31c335bbe929ca76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0f2d09d603e0996bc0c0d58e3c14e0c7664b483f55a35df41b04fb388dc02254
MD5 860e1fa0ec4a2fc58e03cdcd7f8c20fc
BLAKE2b-256 ec1dcd8d393ba9afd9b8dc8eea1547649a206ca4e280d44e5b8f3f034c529f21

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