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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.5.1-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.1-cp314-cp314-macosx_11_0_arm64.whl (53.2 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.5.1-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.1-cp313-cp313-win_amd64.whl (50.1 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.5.1-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.5.1-cp312-cp312-win_amd64.whl (50.3 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.5.1-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.5.1-cp312-cp312-macosx_11_0_arm64.whl (53.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.5.1-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.1-cp311-cp311-macosx_11_0_arm64.whl (53.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.5.1-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.5.1-cp310-cp310-win_amd64.whl (50.1 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.5.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (208.4 kB view details)

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

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

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.5.1-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.5.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1499ed2dd2e5d12e9d43284a1b8d4acb6d7cadc9723f74c337573fdea4bb1578
MD5 a93249eb11c7ff14222509be33765ff7
BLAKE2b-256 fdf0f8fb47714367c3280ee045449ac1e5daae87f361dfcd55ea6aa61fa140b9

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.1-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.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5bb16379415b70381ab67995631caf85f0db4fe9f577616ccc8fd4a12896aab1
MD5 780853a2fd98afc113b2b6c3f73c6f6e
BLAKE2b-256 3f98d8d7c055ea6d100057ae417083059bbaf01abe3019698fff5a19bb10f9da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48775fdbd34cbb322afab43bf339d4646e8cc307feff49e4bcc37aa4d057bf98
MD5 71d29f2cafc0e7d2b0906da271926fd7
BLAKE2b-256 2c1abe232d50a2ad126aff1ec8065e20e4ff5e81d6cffd1e49ceb1de698334f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e977a2cdf49b36202f0b4949bd1c907c560f791a7f710bb3169b35308bdacdcc
MD5 eea463960446cf603000318fad8d1ef0
BLAKE2b-256 edf1ee3b45cccc8820f83c398074aa2cf4c97897adc7029afe5a45ef09db0121

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a5cd1c553b97a729ab17266162c064e626210718b43ac13268211ecebde0f3db
MD5 869a53e85fc063180e370a254a8787c4
BLAKE2b-256 ea896431d3fe3a94d34ea9553efe3e026384a923a3a7760fa518b42da935fd10

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.1-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.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 962e030edb23c701618e98e043871d1e443f9ab88a78d854f4a51bddc4bb70f8
MD5 c2c5a16971d51543e0be9469ab11e230
BLAKE2b-256 85bb2572ba966c2642d3e1a8623c9e8919cbd7942dbaa08a581f02ef2b6c8082

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a657dce3185f4a5d3ba8d45341541cb424464beadc5ff46bb769dff3030aec3c
MD5 9544b4184d049334ddb870e8da4c2698
BLAKE2b-256 a2f49eaa399bf584145d5f7dc292b3346673c73483a9873a50427f52d998503b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4adb7691f577c441a8ea74aa227d5b8693337d1380d293845cd081abb114acdf
MD5 0fc854148efc1ef9a58c96634bf32804
BLAKE2b-256 32eae071d068afb4d0a8760e0987043f70d3175a0ed1be2422706a7a82397cbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 016004c7d369ccebafc0b0c13b6e762c2153df03057e08f3d8edcc2fe94b4ecb
MD5 2925587715defa5f5eac975c64ec6b8c
BLAKE2b-256 52c9ba39f26c50facc06bf4770f3b2b2ff8c790dd8f62b4c60f93890528bea38

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.1-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.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 fa6fa12b7d79a62272a3813a174891b3ec2a0c8363c36c111ed4abab5fd09eb7
MD5 dbe6633a565433f331e75d43c37acd9c
BLAKE2b-256 f4452f94123a37fac1aeae3971d8cf3fa6dc9317699ad3b7b74c3797e11db727

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3764221ee5929239d1ad4f2610701de04dcb57b157b3be2709510501224be1c
MD5 48811b84ddac0467e02700e9041a2b1c
BLAKE2b-256 ba21ad1c30028c47967ee8a0147476cb791371f272ba6e127a3d78348193048b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 41c146469658d5b7e46021b9d2839ac837200a49199a684a8bcbafcf8e15936b
MD5 ab1f091e236d174d3f9d13c3be983b8d
BLAKE2b-256 4c49aab232abfee57aad084d781f79a811c597f22ac922e8c8375b0648ef0c80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 09ebe70c5e7f67cb90f210cd350e7dfa474319e140bc68dce95f5228563998a3
MD5 2f9d8e05599a5ec1254b1c6bc85edc43
BLAKE2b-256 ca6112b8e399550320d97c46f6d8f9c9a5bf7a269707209fc35d8637d821aa88

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.1-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.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0e27f97560c30a7e0a746ab3b90ce03c4a92a73c5e4fda4c0b687aa24e2c7077
MD5 4fbb2c68e2fa65f08a164630b926b6b5
BLAKE2b-256 96610897131f95c2fabb197b4f89c922025c7d243853b7d0120bc33dbc2648f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 89a115e5c1153e3b02d36c513278c8bfd51fd9eee5854dab024bf6fee4e3014a
MD5 06e54ad5641a2162082eef59e6b57b86
BLAKE2b-256 b12c903b728437eb8a826c654612d0eb4883ce900643180f87baa4e10def0bee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 19cb7cd1d7b20c9d159bdd9a9e600183ea5223cd75bdd65346c29ab8d2f382b5
MD5 99fc7649d0d5d58e8c475d71852aebe7
BLAKE2b-256 3466d07fa2c9245533768d44e50a797215ddd21790a888fca1838bf0213fde7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c0158215713894f877a797f88407c48b348715456f754e159fdacb303404b46c
MD5 6ecdb5f256a753d9a7ec9c4c6b1cffbe
BLAKE2b-256 e4abf54b90856d9891cb427d57932c4c6375e027707cc8fa3aeb6f12e4dafc6e

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.1-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.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0de5176fa145b5591ad62e15f3a31c48ba36f983291be3d0a36807ed3c2debf9
MD5 955aae20e48b960c1bdeb9d2b46e7541
BLAKE2b-256 c97684f0f0eb76c784388798d2db16713f03e8453c251e8a474c5082832c96f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2c20bdad79b56860b482a0e211fd036e8be2fca88714b4e19912d8d64c40b3e
MD5 8e5bca99d15ae5b66ea896b89cbacea2
BLAKE2b-256 2350cb82f2c90c2a79922ffa928453ae2b7e3b2239bf9c03ca9a19965279c569

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8f41428e17d15eb3434d2601a731f40d1e5dd29c7061e4e050976e1d3ddc2d39
MD5 7ff8611aa2908d74bf2aa83f22bc9a20
BLAKE2b-256 0fc2a8f669f65f89a675a0cf6e15fbecf7827a68e41142b0aab7c0eaa4c7ea40

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