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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.4.8-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (217.9 kB view details)

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

pgpack_dumper-0.3.4.8-cp314-cp314-macosx_11_0_arm64.whl (53.2 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.4.8-cp314-cp314-macosx_10_15_x86_64.whl (52.3 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.4.8-cp313-cp313-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.4.8-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (219.6 kB view details)

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

pgpack_dumper-0.3.4.8-cp313-cp313-macosx_11_0_arm64.whl (52.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.4.8-cp313-cp313-macosx_10_14_x86_64.whl (52.1 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.3.4.8-cp312-cp312-win_amd64.whl (50.2 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.4.8-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (232.0 kB view details)

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

pgpack_dumper-0.3.4.8-cp312-cp312-macosx_11_0_arm64.whl (53.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.4.8-cp312-cp312-macosx_10_14_x86_64.whl (52.7 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.3.4.8-cp311-cp311-win_amd64.whl (50.2 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.4.8-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (222.8 kB view details)

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

pgpack_dumper-0.3.4.8-cp311-cp311-macosx_11_0_arm64.whl (53.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.4.8-cp311-cp311-macosx_10_14_x86_64.whl (52.7 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.3.4.8-cp310-cp310-win_amd64.whl (50.1 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.4.8-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (208.9 kB view details)

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

pgpack_dumper-0.3.4.8-cp310-cp310-macosx_11_0_arm64.whl (53.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.4.8-cp310-cp310-macosx_10_14_x86_64.whl (52.8 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2a74305a81138689f58c50720960ef0dd2c6f8e354c46c942892fe8f1f66e8ab
MD5 22f52ffb23935554530719a771dbb63f
BLAKE2b-256 af27f0d035759a7d56eb330ef6e412529f502285854790f010f1e4ae2845e1e6

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.8-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.8-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2c7a1b21ba997480eb52f8b91e8c1462b958c28fa48ef6c13458ec90170d5844
MD5 1169f4dbedbe67cae8b5b0093bf28bf9
BLAKE2b-256 a46a7531ebd6e4da6c276078f4e9e2dcbdf20c5408d1a0d0b6dd18374de3faba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 216bd527bf4fd267be8090563ba421e9c08fd2938a9af1311c236f37f6d9f430
MD5 9a92ae95443ae878eaaad0099c6afa07
BLAKE2b-256 40df65c1bf13f836335f7decd6fa142fcb251e0426dddd837140c9391f7ede35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9592cd43c2bbfca740e3c61e8214828e35abf608558159936b6350084da792bc
MD5 5d409f0060a29669124a5c9d21933048
BLAKE2b-256 64f8d1f391c4c4f610bc96a2c79eaccd1a0002fb649fecdcb983023579a88c8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3fd1cc2da4bb45991704dc304d993456ebfff7ca4c60b54c934f6f71b917b3f1
MD5 b562926f52c0f0f6533e2e3b5d1fced5
BLAKE2b-256 44215e7b3c373bd57ed2298fb8d35ebc885c1515bec254fd9b95f2fd4f901de2

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.8-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.8-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ad91f9557d23ebde0c6aac510d48f7e4d79dbc301a5b23c4e88c4b2d61e56e73
MD5 098c391175de94de93cc4418876ecd21
BLAKE2b-256 4a5c7b216eb1af5c1d8500939608a8191072ee1f3e650c6598091275992e5a7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ffd071349efbf5b9cfcf1b7e36bdfdf90455ed7ef0d08e7299c28ee3805b313
MD5 cd95ca9eaa01509a10858be2908f4892
BLAKE2b-256 5c1b1ec4c70006835b1298c490c9481d694c12d10d289bb6fcf5a3576c172c1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 882c9e260502bfe20607749401e2a382d3d2666439c29fac83565ba8dd211fae
MD5 80b57b05e491d1a3f9f9ffbe0a3df15b
BLAKE2b-256 3f78fe604a79f52ec2438837076d0cd06aa15198a3c92f4e59d72d1719cc2423

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 09f118151e608929f71e419a58926c9f11bce3b07af55700f6d74c7a4ed8a37f
MD5 8d83e3c53430dc4d5604eeed7f3f4069
BLAKE2b-256 22248b7e8910763ec499512aab1ee379300793f249f627dfa361431a547cdecf

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.8-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.8-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0b2d3ec5e10f8692a2f88545017c50df037ebeab2185440c716e01c9cf08056b
MD5 1cfb6fbff9525e03176ccec39f2303da
BLAKE2b-256 a884eade8f8c335c99488552950a0d0deed2ac70337c756d31241793d59947b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07e1d22dea049ca7fea72b78e0ee8a662ce8166b9e4f6ec9a2f6809e80d87af3
MD5 45790c3a3742d87c1a1e77b68c9e7a0b
BLAKE2b-256 96e9d8b9fb6521cd5a50c891ccf9efca67799aa747dc95f54274f0e2d251a7fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 61dc94dc77f456da9b6ab91414010c7e554dd7c9fa819fd62a6c476dfc131eb1
MD5 57523629e2ec05e8262efd24615b8fe1
BLAKE2b-256 6dcde1b7243452a72131a9efefc734ad15f0eb274364de130a480556bc83e7a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 638ec9fa3b0e9652e094c5dd845edaa7cddf3ed3685768005afea8cab055e22e
MD5 e17b146e32329e7c5719463032a5dd37
BLAKE2b-256 4d04b7fbd12460f60ae1a8023ca7b2e100f10b371ca9403f3141f282c5a7e160

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.8-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.8-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 d6399c07330a03da35a1cff68db1f8fb3a18c5d7488f53794c896b5ccb7af950
MD5 a219421ed03cbead998ec7058ae4cfd2
BLAKE2b-256 9745638cec60f1beb8ff1ffb69a4bf21d19c2858ccec33e0e19a462ebf7c9286

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cd3818f1251fbf8d43c8abd44ebcf884f7dd02d25be994f16a08b23532ad4be
MD5 b452410e3a5d06c4e7c4b7462aeab1c8
BLAKE2b-256 c18d13e8795a7c375f4f236d3d4f2d9c3645f5119e9225ae924839b45a6c830a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 752e7f3cde31e9402c4987aa8cb74bb672a81611027c47aa965589149c070322
MD5 74aa7c2adf2adcb5c226bc76975a477e
BLAKE2b-256 d67581c326472b64c873d28c604e111a1a65ac6351362dc1e003e397c5ba8bbc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 acd795d22c80900dd8f67c0b7b33f7c1506b6415f387ee56e569c6c562577ccb
MD5 ccdeeb3a48c0229b1cab8cda54f36ca5
BLAKE2b-256 31bdfeea5c3d6b1b42552c84399538c87581059a2c56a8189698a15b0b49313b

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.8-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.8-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4c81453ebd7ef479e7351a09d4777497f98e161469fe323f9e24ee26f12a6457
MD5 d8d777b5a7ff690fc9d70fc5667835ab
BLAKE2b-256 06d039ac55ad85d409845f70b828b31045abdaffa6c36fae47778223f0e4a063

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 905ab98b89b81c8064e64b2a7aeceea4e4bcff02b8b4052a0c80dbece53198a4
MD5 1cd72c3713e8cbb5a266ca678ebbdab7
BLAKE2b-256 b7242b9f161efd6d28f9de23dd0132ab1f53d7ebfd83a6c299d1cc174e966a69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.8-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 32b4116f6679eb858d9ba0b1d2a6f5aa18c46a5ee086068fa673fa00e5837c8d
MD5 63844799c6e649d35f6e57be2a0a8641
BLAKE2b-256 e6d1859a4a8e6eba9387272e2d582a8ac05f926aa59b4c1de1f3a9e6fc5167a4

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