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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.4.4-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.4-cp312-cp312-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.4.4-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.4-cp312-cp312-macosx_11_0_arm64.whl (53.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.4.4-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.4-cp311-cp311-macosx_11_0_arm64.whl (53.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.4.4-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.4-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 4270868da1b2b6affe298ebc7597584dc86e6eee197708f7943dc6a69be66fe8
MD5 a84cfdc5625a5653e67206bf7e1e3a33
BLAKE2b-256 16212914166d30feca8a0dbe5fa8439aaf4b65703a03863740b55e60266d131b

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.4-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.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 82cf61bee103bfd9fede98b6288f2fc931549a8bdac27ca2e3c5d3d49810e942
MD5 eddba0fd077e00cae7f8fed23cc0db06
BLAKE2b-256 1d3ca111c95ee127f8df94c49c0f1ece9b76e4fe85fa35cf3feee53b126fccca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee513fdd6a4299d4c0148e79346783796f92c7392f08838b3c12a99daae13cbc
MD5 896b01a818ee3e4b42818ba0127fbad5
BLAKE2b-256 4d75975bc57205c40751d788ea66849ad4b318a73d19476a434f5dfc7e7dd13a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 28c9b616d046174b8add678a98bbc854f4171437436968140e542b89c9a298b2
MD5 8c364878ae608a0378ebc312292ba7a3
BLAKE2b-256 d6a66c5a6288881e97cd4c145d912989fc816034271494c3e555b1b40038e13a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 555c369aaa4efc972d9929147e91b410bd436c334936eaedd0f1febbc94601fb
MD5 29b1cedcc92f5bd5b83d7b8162d4ec0d
BLAKE2b-256 e6d9d7eb7ccb5715a2c23b8b4796104c370e9d6e4b4f9278cdb45b8332fd16a8

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.4-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.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9bf1f24467de8cc6f23bf4ee3efb070c1f489bcc42bdc251f84b82c58fdd104c
MD5 4ccfa6c74bd6be1dc923ef2de6f2930a
BLAKE2b-256 95a2c61564d4845a99b82f22f298f563387a175dc354e9fa0a2a9c72a6519eba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 add97ca4109a1591849d97a3a3bd83a653cee37874088e945f8a4f0d226b60e4
MD5 7ca4955e5e71fc9dab0d2d5b6fd0bf09
BLAKE2b-256 f884d995218e2f147ef8a51eb27387bc89d46038ce2704975d6ced9252b87913

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b141854cbd88e9c45514ca394b0879423c160a361b615cae2503c59b1ec957b2
MD5 2266d84983fc4ae697a3fca87c56e4e7
BLAKE2b-256 6fa1b5388e248003ad779827ec47d1719b060d63223ec80abdb4ea9058044b33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 36f44f6be42f8d9512a9f8a27fc0fc38e3f4ca6e3dfb38d18d2f5f05f0183987
MD5 f53b1b171b2bbb001347378a2fe00165
BLAKE2b-256 1bfea2a498066f93f5277255cc8ad86a93724bc2255943519ac80e47ae016e00

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.4-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.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 249befa098d4aa85ef187c4e3d44f023a2425c1551300abc9d01de1f17f6e5be
MD5 78bd6a9c00ea5de61319fb02a1a8cd7e
BLAKE2b-256 9baac7c798c882510937c207c4e6c5b6f25a2123d780519e838f270c3563deae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 869fc27d102df520788751172544a86215e2ba374890ad91178e1aaac06752de
MD5 2c6c8668bc72d1540bc4d0d10b8dd79a
BLAKE2b-256 fc0430327def9dad59c24d9e5de8481042ebbaae1b7ca6c5ebeff65f67d4a2af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 e7d29fa926d585f6616b407f7c833606ad25cd299925954b23bb9a02eeebc1c0
MD5 16497286cf61171408100831e13771be
BLAKE2b-256 8e21b6f0ef8f65d9c2b0d4a90adc1c07b6c05267fb44ed7bd5863be9bd4697eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6f3e667a120640d8dacafc4cbed8fb96a1a8ea8ddf9d5a86415f7c0d7cd151d3
MD5 5c0108e28ba0852600311ecf347169d1
BLAKE2b-256 8c948ffafe2be12e85d99396edfc02dc64d9bdcad025cb2efecd81db4e66d073

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.4-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.4-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 09814659e0377e41c7e3e4eaa44f831045495ea30f22a2eef86f0ecd70b867c9
MD5 9eaceee628d495003aad7ed6601c597d
BLAKE2b-256 bf4e83015d2a3e324bdb07460d4f728286295fd1cc52d5c69035b23ec5adf1af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e2e3c5a1d463abb48d21c1829d2408a835e71663a4e7c63ef18094b09cb5dc6
MD5 864f37f6aefca8ec472ce83ead60b2d7
BLAKE2b-256 174c516d8dd8e77832ba668154948388f77d365f66a066f904e2a6d323888eb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 228ff6982240fa17f394cbffd3bcf9339c31f29bfc7717de8bbdb078eaebf0b1
MD5 b5bd8baf07b8de201703dc138e33d513
BLAKE2b-256 6e48207e29907b683b28104175a47e056b64b3b4d22237e5065f87ea0338941d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 68f34b61688a16beea97f72e669336b3e83229d90750735bf5c92f414bc47761
MD5 19b88a93b68f1d8a135c531479a478fe
BLAKE2b-256 738011a15a11b12540dea1f4190f947b99003c5c39c6bc7a005eb5331f5434d7

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.4-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.4-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f779f59320981d7096c272189262918bb6354ad9b6b53bd98836b140cefcad78
MD5 58cbbe2f982f50835d79b8a4e00f792e
BLAKE2b-256 e48aacf065a9016f2cf401daaf7c2c03dabb754180a7716407d3ea28d5a962c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57375912cbefe7e3b1e352fc6e342058ec5e6a668929df187382134b1c6cdd01
MD5 b2c3dcb94514676838fc95019924fd44
BLAKE2b-256 3c2082a8673430beabf641ac4dc0d182932ca53008c8c8ec0e801af6ea077a7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.4-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d502fbe6c5aa97b446a533c6daa1968e3c32b55b600880b59f798f70b9b6d220
MD5 2d8cef20f87a494b3f5eccd4cc6786c2
BLAKE2b-256 68449f1d3ee5a94ae6adf3efe65b64a4dd1b75b01d64ab060384ace2b8a8c68a

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