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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.5.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (217.8 kB view details)

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

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

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.5.2-cp314-cp314-macosx_10_15_x86_64.whl (52.4 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.5.2-cp313-cp313-win_amd64.whl (50.1 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.5.2-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.5.2-cp313-cp313-macosx_11_0_arm64.whl (52.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.5.2-cp313-cp313-macosx_10_14_x86_64.whl (52.2 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.3.5.2-cp312-cp312-win_amd64.whl (50.3 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.5.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (231.9 kB view details)

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

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

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.5.2-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.5.2-cp311-cp311-win_amd64.whl (50.2 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.5.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (222.7 kB view details)

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

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

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.5.2-cp311-cp311-macosx_10_14_x86_64.whl (52.8 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

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

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.5.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (208.5 kB view details)

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

pgpack_dumper-0.3.5.2-cp310-cp310-macosx_11_0_arm64.whl (53.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.5.2-cp310-cp310-macosx_10_14_x86_64.whl (52.9 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 faa51752b2476a51441820e7cf3aff342bfaa67e075a08af8b21c3cb28c042fa
MD5 9364362e37121660c0c532eb5837d66e
BLAKE2b-256 25c16399bd67db084622e243e7e2f2beda6252c5d2fa6d1942c1daf12bca5d92

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.2-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.5.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3e09ecd507eb9f907a568b529cecbdc49b4ee1081e6038a4e723a2fb7e333e67
MD5 67c276e4e6db9b2ab964f7af08c92559
BLAKE2b-256 75c833f674ac74ef1ef6615719c88b1b4e925caea1225c84b043bc407c46d886

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c0986492a20e0d7c0cf0abf7a1ffe5dc29d76cd654a2f37b139f1b5dc168b46
MD5 00dd5156508d5b2a5237f4a0b3e197f1
BLAKE2b-256 84ad7be4ecf8979e21be5df42a446c43644b3ca06b55c5e359bedb5d9f774ac4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 61cc3ab5b38d377b528677c8b9bd8740209c81301c8e8beaa952ae37c00317fb
MD5 e85edc1d686e1ee2e31dd2376c05be6b
BLAKE2b-256 f6c55c9de3729b96fc044cbf924e110dab46289f019c144929e2af5fd80474fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 81e77b2703468f7ffad2a6aae8b0e7954729b4d00ddb4cad5934a327dad85dcb
MD5 941231dc9b202164b2ed3ac2a0cd0cfc
BLAKE2b-256 09421603516eeb59aa8a89fe632448a6bec3280bdd9923bc4197f8c99bb468ff

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.2-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.5.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 7d87c1166ec96e3571e09dd987e04c2826b340ff0035bb311c9935e3e1fbb3d8
MD5 9a0283c355729373b4b0c118ca7f8b0d
BLAKE2b-256 51510ef49a57db4e823c87dbb37eef43c44867db202d481ae0729301889cd0fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 65957acd1c1855dfc6e0effc0771ad1bea3769f70076166369a96fbe25a0001b
MD5 be244fafb229e56ca50abb2e76ac8674
BLAKE2b-256 0fb50df18b2b8f7805a37f99cff05f41f6592bc6e7c6502da360f10bd4a4d6ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c32d1b887baf0436d78a1b6eb62f60e1b3087cf4c98ec302ce1014d954aa6345
MD5 b44df2fa2f178fb22dfaebd2b40bf18e
BLAKE2b-256 001d8257178f39c474c10371c90d28a026de86d5b72d73691ea7594ebfc7e0c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 eb4af507e300dc616cdede8569fe97d9a5967159848b86b3ddfbea9c2793469a
MD5 c35e614c8116e927ef9e67d0eef449e5
BLAKE2b-256 e3610e88974b2370475e685b17fd9ad2c210221b9b72376f872001a68bec16df

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.2-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.5.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 1479a7fcd93d9322ac5f495bb14dcaec424e3e3b114efa86b7e19dc3f5f28ea8
MD5 15f2948a299a26b55e28087115e787a7
BLAKE2b-256 0b81955047c08e911bb4646c29c627e42ad6406d93160483d4f7e6a3fe0f9065

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7eed81ebbd0f8388df08db6f676e6bfb7600aa1710abc60a758dc831356aa2e4
MD5 9562a8c4b00ff4a35de7b188fe99b306
BLAKE2b-256 027cce92b74fb48085ab9c566ffec298d1304759d22f4e5787a5dd3daf2bb38a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8a8c50bec36aa84dfe668279c186cd0770fe55d5fea7db606036c61979f6a99a
MD5 72c56cda9b8b59409e934c779ad640d6
BLAKE2b-256 755a30cb87190ff8b6b099eb9a1c964e1e2a7c42f5ccd534e62ade132c78ee22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b2a33100c0513523b7fed475f378c8f4ee645e29ab2876bc95a9042a427dcd3b
MD5 17b7bf82db1ff076471e3c2c59d485d0
BLAKE2b-256 476ed89dc1b3486d14d27e93165cc23762f6f47f2b3360100781703cd055607e

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.2-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.5.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 826ae1fabc7a64cee75ace751d70f23c03101051f0082aa26ffe0f5df6c72511
MD5 9e759c7b02ef4e522b309bb87d263f27
BLAKE2b-256 0494f2ba41b49ed8d27b07b5bbcd88b9832481007835a9599def9e92f0b5e863

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc9212c1060c7b41066a0b938bd0e7c09b8b7d992582151476580b6320f8a063
MD5 0d1064faf329a26c84bf00e91fc58cb3
BLAKE2b-256 4218ef89e717fd8ec3517cb18a3a88dde614f07b8024ed9c96ce575397279afe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 3fb17e8586f69e1fc11f93283c23e24b4f30e4477dfc284acaf6941526b02565
MD5 e254f4b4cabb9e96acb79d762c379f8d
BLAKE2b-256 ca4d3d7a4ddd5868055ff3c0fbe642f6f12068e8f6bef5ab066c2025be833af4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 52f6bce0db75460c96ac44f0a3e77fcb442a3426f1fe52a9d363a2bb8a336c8a
MD5 e71a2d5dbc2de3b55de3b54a23a1966b
BLAKE2b-256 458f343706a7485a259e88f9869e5f0f7cbca267197670e2e9d20c88c0549161

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.2-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.5.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 01e2165d883ef92bf13a6a41b58ee920d5afac5fb8cb1b70e11f671717d48689
MD5 8d319ff0c3852db980bb0c53bfe0d5aa
BLAKE2b-256 ef363c53ef4d0c804c7e2f4a3e714b24799a6041819fa17827838cb9a1e1bdb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dbb4365b6e3e2db2bb7a45880efd91ace479e3a3d0700c01e4799ae5c7e73d5
MD5 3432d231686040353f8328532577577f
BLAKE2b-256 4d68d30f70ccb7cb58aad60ff55a0b4030c3b2b5284d6900ca4791549450bb60

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 90362583a9716ef75c999a3d7b369fd98628d67747913e53f11e1488ceb35569
MD5 6263b492b4a7fc41611c766fb38c5bb4
BLAKE2b-256 ec203ebb071d1075b85153baa085616c23d6ebedb890c6d00a4379be1b2b896c

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