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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.5.3-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.5.3-cp314-cp314-macosx_11_0_arm64.whl (53.3 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.5.3-cp314-cp314-macosx_10_15_x86_64.whl (52.5 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.5.3-cp313-cp313-win_amd64.whl (50.2 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.5.3-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (219.5 kB view details)

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

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

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.5.3-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.3-cp312-cp312-win_amd64.whl (50.4 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.5.3-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.3-cp312-cp312-macosx_11_0_arm64.whl (53.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.5.3-cp312-cp312-macosx_10_14_x86_64.whl (52.8 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.3.5.3-cp311-cp311-win_amd64.whl (50.3 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.5.3-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.5.3-cp311-cp311-macosx_11_0_arm64.whl (53.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.5.3-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.3-cp310-cp310-win_amd64.whl (50.2 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.5.3-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.5.3-cp310-cp310-macosx_11_0_arm64.whl (54.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.5.3-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.3-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 5a320df88071dd7ee430ee3464da46bff672b9b3baae955933adf494d9f24ed7
MD5 b8ba91a6bdc443fd298e4dca02fa258f
BLAKE2b-256 254d4a44708ad552c95dd9f677486c2179f8f32a686a26410538d6be9fa02233

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.3-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.3-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 558af0fdfa0faea266140feb20de2dd27158a87bc42c4e9bfe23bacde91a25c0
MD5 58399030dd789f3fe9b44bc73ba75317
BLAKE2b-256 7baf9fa945a389a0215688c961bd06c193393ef71d0e5f3bdc3c70e0df28ab61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03e29f242c41fffad63cc911fb148233a27da9dceba277365b7a2d677af265b2
MD5 3427b347cb8a448aa9425a6b85856c88
BLAKE2b-256 68c53cb4db095808303a066cd2b413cfbf55a37462532c08e39aa3714b4db0c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3907215f34a61edffca5091d21c4fa1ae9f0df6e6d4e0b6dce0fb2a571422334
MD5 9d45f615a954e0b757743b68176fea4a
BLAKE2b-256 e2638c986d8f76d3299ba1d256ec5b3f5521cadba64a907181de7f73ce391f9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c9acdb9ed20281c59c99348ed4a561a01cecd48b0310377485ef2b4abb094f71
MD5 26a3a56a64e5d9ab1ee16945ca18d9ef
BLAKE2b-256 7995185109ac834b754267c4a8b9ded07166dea76c32f2f33b73f39163de5cbf

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.3-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.3-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f4d7c4b5b2555e4093449f57394d73c5d8bc336228ed324d86568546aa766034
MD5 de1ae59935d16f087fecf1cec6364465
BLAKE2b-256 2feab69f032ccaf51282a663b9747454f75a0a53fda0a91ac03baeb820e8e9d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5c7918c5d63b0aeff3685a29bd357a430399f9c00b12723825ebaeb5a512254
MD5 1a43619d3904145c3b3089f29fd2c9e8
BLAKE2b-256 879385e5ae477ca81acde767354b456bbf40e30ee79805ea6f0461395c9e2aef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a464d4e3ddcfd153e25e32665659b33a738501bb45c61d2ff95efe13cbdf307d
MD5 f9c6835e92855524b29d525a5b70f165
BLAKE2b-256 b7191b120a05e553f488be5605ba864b5e106201d0f64ea76afcfba7c7c676af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0200fd715fb29afd708081ebd700e8f3edea2b1e51a3271bbccc6efaa5202bb1
MD5 5c8680b85bea377a33f8302b77afcbc1
BLAKE2b-256 3963f158151bb428c5494a65c395375e85d00e4b6c6bad4bea8a398f09fd24dd

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.3-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.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9d58e2195fc1fe8ee3e747200524a5d734f492e3b4abe52d60d05b84014f1561
MD5 25a8240a46d8e4bdf77a4954774e6dae
BLAKE2b-256 7af72550b0704d3e321c960744d5ca2e1ef14c77d4184996dac9ff4e2428c3c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb9a229f12711d457f2ec15bc71e4cb859a1a6e38e35f5cd941e9aca589e5cf1
MD5 d8f49ab0c981d5b7902dffb111bce6b3
BLAKE2b-256 83853f7d77d15d41ef1fdf62c93d50474ea586b698da9edbf9ac2fb71c46bae9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 aa1781692861bead8d6c7398180952cb42d287e98e1c05fbc4de49d16e1c43a5
MD5 61665e19190b7a0e18fe037bfbf65567
BLAKE2b-256 99899b158a1ca20a8b8ddb6c318c9894e8f38c63725980b9edded8e91fdb7e15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 34d787e85edb174ce19e80f950efb5e73ead6cb14bbcb6954b9899273604e018
MD5 c20d28a56aab65e6be8e9ffdaf431569
BLAKE2b-256 aaae432b46b2e776ac65c492a3337ef9d862ed18ffce04afbe09594b6bbdccf1

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.3-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.3-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e6ba8dbffbf0ba77d28977ce669f3247e72712cf31e2bd963a11714fa19b4a9f
MD5 8e79d27fe1e4f52c8ff54c2e74f2daa6
BLAKE2b-256 d4efad37357e986f832dd8e9646f595ce3185469137473fb70fe2d2199e16a95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ee46b5949f2471fc5e34d506be092f4ba770f2be828e4cb84dc5d6f33f78f21
MD5 4af968dc6debbca7b10ed855ec09d201
BLAKE2b-256 8df1632eada3f990f91c19b7c9fa2bc2cc6792f80ead4db0087fefea643f2c95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1f3774a6674be2e94ddfb835e747c91500acf9566dd1c883076db6183cb133e0
MD5 ef948bc330132c2b142415487b65c029
BLAKE2b-256 ece00c1b36a88d2c828dbdbe13d69541f806d09aab82257c31de845e35400ee8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2c7ff7e59be2245e172f4e09268aabad8a3c0d755da7ddecafe2810a8226b14a
MD5 415dec9c919d97845497fe830df8cd8d
BLAKE2b-256 ddb0fd5b9cac61ef651c74e51b9575e8d64f406561ba7174de516085826c1808

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.3-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.3-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3d146c9d3540af14ea0b53b00d33639d5ddad0041838338afb58508a4d67afca
MD5 37a46649b053ed3fb63191330c0ae1a5
BLAKE2b-256 e981ee657bbd435fac2120fb9d66347e1e6312652f4d91c39b17f81beb65d307

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7d31f9b8b27553691afcd6ad0b9c0919d6769b016be764f4adec024257bdd8c
MD5 9664b19de79ad7558cd5ec0005312db9
BLAKE2b-256 e557fa40040ba88d36167bfb8520fd909538d6b4b03484a4f591ba9ece45961f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 40833aa18f82f49f296647533e13c2f83680a757d6f1b5379efad56b0c131c1f
MD5 b7dc35f023d6368129b74633fd92141b
BLAKE2b-256 4fa5b7d3fe4d4a6f6fa3afc04f67fd73fbc296ec44da97721943ca9b13e14b73

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