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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.5.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (218.2 kB view details)

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

pgpack_dumper-0.3.5.4-cp314-cp314-macosx_11_0_arm64.whl (53.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.5.4-cp314-cp314-macosx_10_15_x86_64.whl (52.8 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.5.4-cp313-cp313-win_amd64.whl (50.5 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.5.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (219.8 kB view details)

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

pgpack_dumper-0.3.5.4-cp313-cp313-macosx_11_0_arm64.whl (53.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.5.4-cp313-cp313-macosx_10_14_x86_64.whl (52.6 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.3.5.4-cp312-cp312-win_amd64.whl (50.7 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.5.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (232.3 kB view details)

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

pgpack_dumper-0.3.5.4-cp312-cp312-macosx_11_0_arm64.whl (53.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.5.4-cp312-cp312-macosx_10_14_x86_64.whl (53.1 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.3.5.4-cp311-cp311-win_amd64.whl (50.6 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.5.4-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (223.1 kB view details)

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

pgpack_dumper-0.3.5.4-cp311-cp311-macosx_11_0_arm64.whl (54.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.5.4-cp311-cp311-macosx_10_14_x86_64.whl (53.2 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.3.5.4-cp310-cp310-win_amd64.whl (50.6 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.5.4-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.5.4-cp310-cp310-macosx_11_0_arm64.whl (54.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.5.4-cp310-cp310-macosx_10_14_x86_64.whl (53.2 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 06a00bb1bcf72f974e41a8d20da09fefe23f11dd7cd30b23a945a16931c2e056
MD5 1b4a38531fe3f96cfebe17ab91c68dec
BLAKE2b-256 5cccb1708ccd265471ed1602d2b12928d8de5a1eb89b6c332fcd2b951a73d60b

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.4-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.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 00e90b979cf89a9f4285a36ec380b11e6afd414d7592196e61aa956b73f80424
MD5 ce0a4feb7ded68590234d2b8e742f7c9
BLAKE2b-256 35dd3f5ecaffc840f519005ec417783877bc17384d344c18acd5af3c54a2ad50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a82855b3ffc2a0b9595976dad7d6a94de4de6bc9b4cc6edba12967cc81c6632
MD5 aad5edef88d5e49e615af8fbe7b522a4
BLAKE2b-256 1ba3fc3b3a485ff02ef0c36c901a403bc2368d434a925296b1cabb24e92abe85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9e0dfc6abe587756e1af553b5e9fa7c409e426ad9556d03ebebb39f3ff591d3f
MD5 b0bd7e5f8d217cc597ee2294b9bbfe00
BLAKE2b-256 de6446975399cdc2b185c365fed9e1081f8098ce37807b1163f9ac534836c402

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c0de6fcc8a7729ff27dc037a5e276de09f59cd65fae61a54707a34fa8dc5929d
MD5 4251f223ecb9a2adbf75c4a849e15592
BLAKE2b-256 942c086f0ea22b993187d7fcccab89eca35abf4f1202c351745a38fab82f2de0

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.4-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.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e13d1d83dee550a52bbe37a6ec9d4f9da60b7d56cf1cfdf93db82d7ea32509b8
MD5 dc2d740fc6f6ffaf52b04c8694b967fe
BLAKE2b-256 461e2844d2085f83b66c3dd269200a33fec4a234474b672db0b8be7e5d931b52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 935bc58c3e337edf6e10ca239bd872a06ea72160830d2301d3c49168974c938f
MD5 2c8f8cccd9d552e51197b5f875109469
BLAKE2b-256 41dbcc7aaa0c8757d6e73a3411c904d5ad6f2544a9894686efd9c98863f2497a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 bc5b8b2a17391cfb712b4535b518d965ff1a85131698c1626e6d25afb1dffa5e
MD5 dac79973819f71b131d9ad7b5db996d0
BLAKE2b-256 2149edf293269d1d3916f3c4ce7058827f79139c4d313e5684231f1161475704

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d417a65ba76d4ac482b7e9180c22f230be39b410ab93e20d00a5a988a2c30afe
MD5 616008a108ff7e609f219992fac9329e
BLAKE2b-256 1257b41e1ba8ba22f6fe1222fe548076642c1c223315159f2f8944c552c58f0e

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.4-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.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e1fb73b410afb411e3a0bc201bb5a924a74cdfe5ee403d9b830a49cfa553cc67
MD5 06be8b596be4ad14dee384ab20a82583
BLAKE2b-256 2a4c221aa36dfb2022f3bb15de64c297ed90ecb5203956c1c7d7fa289e648084

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c09aab2fe28bfef1e7174a5d0e0443ccaecf200d9c81c58a527387243bdc994d
MD5 72c7fb275ab56c992b078b2cb6b551ff
BLAKE2b-256 ad6d7a01b0f438133442d8fb007708081ba75a31fb9d70e1dbc049b3fce8b4bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0cb8bc9a07e36200166f38945ef910b8b696e1549f29c1efa3e8e295a54adf2b
MD5 b9d3a2e57f65183fd324ee096aa8e00e
BLAKE2b-256 8e63bf266f706b3e44968e35483c3ff6da02a61e8d18f39b87cd0e5571028579

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ae2b0d2305952130bdedd18e75022c163b62c1cee9488d163e9fb00ddd07a641
MD5 2b9055c36133bb6d1177f2b67966c99e
BLAKE2b-256 a9da4c792890b721bef00590e9f80aac1b4e1194a08c368436e42840bff9a740

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.4-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.4-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0d0559ae8bb5979086141cc91fb472b1bb1942e8e0c9ecc917d92f1985fc7c1a
MD5 c03a569c8493be77901634ddcb1e43a1
BLAKE2b-256 3c6eea77e58b7488d922d50144faef30649ef3d1fbd060879b63a6a5237304fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3171eb008ca11c51f1bcfd94c79b070801c53e776506dac40d1804226453980f
MD5 69d3b47c33d02f3886624a84d89f1be8
BLAKE2b-256 143dfce3c43fa6c2a11044fb6347d47c3770eb7680511174900f8ece7d6eaa43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c5bb5c9d5128696fc5f608f458f8610cc0a31421f6048f0d52e3031b2a46257f
MD5 5601a7edc7706f0958f1d1ad314ee272
BLAKE2b-256 bdbc58eccb1674b2f0e2e3fe57796b3a245dbea4fd27ccfd0ea406f22a01c4a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c97c17bd167ef569db9a850914f7141fb8659e5f9bfaeed37c7931268a37334c
MD5 613015729b4635e770cd8ca0e931a169
BLAKE2b-256 1696ebf5f71215d78543a192eea183a1f097dc55ad7512b854cb6ad904c77349

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.4-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.4-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 291c95659fd3bd25a7a6917dcfffd7f1c8c253ec832662a7cfa3c8d74234a530
MD5 d48ba14499e329eba372f78ec8680b5c
BLAKE2b-256 23530843ef38885bab1d5750e0484b1e5566987c7733ddc58b51201faf134d14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e457e8bf87bfd21b476618aa474bd35aa28e0e006ec6daa34fba9bfa31fe11e3
MD5 50611faa435bfa0d24efb4040de6aaba
BLAKE2b-256 a12a2375d895415bb6d1f8bbad7a1ae2256040270a203fd66134227b344fd77a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.4-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c8156085b05e037f3d717632c190b356b6eef4f1e91b05cfaa018f7b5cd613aa
MD5 a228b7e4c17f0b9fa3b2d1b6456d9e6f
BLAKE2b-256 546df34d0d59fc27e0b41406bb7130f032c468b4e0fc35cabc8adf86e8a1c4e3

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