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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.4.6-cp314-cp314-macosx_10_15_x86_64.whl (52.1 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.4.6-cp313-cp313-win_amd64.whl (49.8 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.4.6-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.6-cp312-cp312-macosx_11_0_arm64.whl (53.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.4.6-cp312-cp312-macosx_10_14_x86_64.whl (52.5 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.3.4.6-cp311-cp311-win_amd64.whl (49.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.4.6-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (222.6 kB view details)

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

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.4.6-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.6-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d05c3373ae04770cb8955f988e83a58be548354940713bd910d0c68b0d3a3a50
MD5 e8f7249917aac405b5a7c8453d08cfbd
BLAKE2b-256 8d351dda4564bb230055b1b472554fb8d16848c4671addafa9e1769e59779daa

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.6-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.6-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 76f7c6bceb569fd1e4211656935b443e888c0ca2e183db298bfca9a7c3ba410c
MD5 5be5c9dbc987fe48818f36603bfd053f
BLAKE2b-256 b125d7d4a909bf3d466b952201b835ee9ae14aff35f088ea4793a806d77e9a8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67fedda559c509aa518dad84f4524893e08e28dc093ce9d742e4e2d31d51625d
MD5 79056b3f287ae050f48edfd3229e3728
BLAKE2b-256 f3ae3162994caf0403a6abeaa0f5b8d83998c042fa88e8d51e08989c95202f54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 10e4b481f96067965d1138a1ae5608d0e5ea0114bc96c08bb5ad1fad2f3fdcb1
MD5 15a0b4203c2c1add2041bffca6a2c1b7
BLAKE2b-256 1a347cc621e1e76379831724045768232680741243cea9a98131c696d565e188

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 83049a1a55d83dda9b5d3e35329be423ab42bfc2497c154842019c66589f2ae9
MD5 5b982f273e7db6c15cb470193eb2d3b1
BLAKE2b-256 fb6caa8a6e1b80ebafb9144a565b40f5c9fab038cd527cf993c23ea76a4c034d

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.6-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.6-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 35dd637c3f1f282c43adbbda02072fc609d0436fff6cabb6a24f6d5913064367
MD5 6de2acd962f981407056540706d56cd2
BLAKE2b-256 69d00f77bb6758ca4ac856ee3baa37049fe6c0525de04cfb823fd33d183e53e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a93edcd8de2662fd1e6c7aab3813016e7c0f267932ff01ed8cec52b2a2b2f0bc
MD5 4053979a64a1e005d15ba9264cdf1c20
BLAKE2b-256 bab2e1041f11a15ad1213ebd9f5e2beda53ecf5027c431496647a70b46fc6c00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 983732dd1f501a5085ad221d469f590fe8cb819d7ede3f843a485eaa0c7c6309
MD5 4638d76088ce819c4a27b5522626422d
BLAKE2b-256 68796ee9f408da5be402f5cc6c93cb98123824ced84f135f0b35a7fac73a4da8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8bfe4fefd42215d41fe3c860c0da09be4076982b8064c6da5f51b3ae83876bf6
MD5 606f62ed38791e9128e39bf530d85b0d
BLAKE2b-256 f0a9f54d385ed552dfff5b8451066d0f96f9bf13499a70542a1b1fd30fd06fa5

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.6-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.6-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 df330ff98e4fa3203f231db899ca44f10de73de9c06789fbbdba346fba53348d
MD5 2d41bbd2c477152fc8a3143a4807180e
BLAKE2b-256 9b98b517d2f3d699f19d819b955f1c020747eaa09dbc1975d8b378dcebb5c35e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c50fa84587311a96dace790abb74c367e79b480deaf2b266ab42d6cc290a328
MD5 aff701a3ef12eba0b424d007e9c92d2e
BLAKE2b-256 b726db9744beaff2f62224caa66cb6733d02a83ee14615ab7440d448f581816b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 528d2e3c4458e92db123abd34f4d52dd86a2dbe277c062eb6761706f36493082
MD5 071e6e1f8651f39163ab9b04b124a4ea
BLAKE2b-256 0e446c5fa6cc15dfde4f6729a5cc8a56fcc05d8c0bcb051056ff3116f7592bc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 08c5482acff15203efdc1dd8023555d3a6d8b9302240790f4a1e2de561a56ee0
MD5 04ec720e9c05d668d54ae30dfece88e2
BLAKE2b-256 488769d287b9619bcd2f77acb8f7b2b4f0d03b553d21b9a669e76c642c6b5ef9

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.6-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.6-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c48f8067180fdf2a04931c95dedec3e728727f94ec0d5d08ba0fce307988c3c1
MD5 7ae8382132ec529b68f0a1b056165c59
BLAKE2b-256 8807482f2b341fdd9aa51219eb603054607c769582c54ab0f546a2dae23cf0a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4aa9037388210cbf6285e30399462d6ac2c5aa1bdd0e06c25019ad3cdb1a8dd7
MD5 b3a4fab35882a822354f4bf25f336c95
BLAKE2b-256 1b7b0e034a2b59f5d601158b3148da4debf88bf3d6a0b4a59a486b59b62e3c26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 48a46463265488ec6e3c23cbd3db65128aaffe2ffbb66356faf5595585309a39
MD5 ecd8e8cc8df8ca92f7af13fd3eb6b498
BLAKE2b-256 210cdbf011f0504fac01186c8f6e479d4d031a89d957adcd55521bf374fb5299

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d7018638926521d18509ff198de859ef6fd8de200df236dd529341bcf293ff38
MD5 eca8d7349afcbc29370ded1705b902a1
BLAKE2b-256 ec203d355f6eca66413225dde00fc7bcb1781b88c6cfbe858783ce38fe691745

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.6-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.6-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2e398b8477371bf17723c86ef6c69da0155244549b309f072fb9b9d119e1b392
MD5 2fabd8146a9c00faa7c1fbbeb4c640df
BLAKE2b-256 761d9d90d6afd2f74b026869e8282e85c77517114b247efa054794d2e07f8c27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b701ecf4861e6e644db530972b9f9b96aed85f3821a5dae6dc63c668388938a
MD5 9dd24bfa948b423f3f4cd8379aa0607c
BLAKE2b-256 7578b6a88ca4fb1cb4c84c3a228b6647fcdef77f2fb34146ff4f74c26cbfe795

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.6-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8a6c5e65fd21999fcb3528e18a38236c44c720694e84d1605c96a4ad9afbb782
MD5 21cedf63cc466f2c3e52e51eff38eb6e
BLAKE2b-256 eac4e7014fe5a8ed9156a057639e3a6d986a4cec80afee1c634ad0163fedc377

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