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 Distribution

pgpack_dumper-0.2.1.2.tar.gz (14.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pgpack_dumper-0.2.1.2-cp313-cp313-win_amd64.whl (44.2 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.2.1.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (220.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pgpack_dumper-0.2.1.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (222.2 kB view details)

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

pgpack_dumper-0.2.1.2-cp313-cp313-macosx_11_0_arm64.whl (48.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.2.1.2-cp313-cp313-macosx_10_14_x86_64.whl (47.5 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.2.1.2-cp312-cp312-win_amd64.whl (44.5 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.2.1.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (234.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pgpack_dumper-0.2.1.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (235.8 kB view details)

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

pgpack_dumper-0.2.1.2-cp312-cp312-macosx_11_0_arm64.whl (48.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.2.1.2-cp312-cp312-macosx_10_14_x86_64.whl (48.2 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.2.1.2-cp311-cp311-win_amd64.whl (44.5 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.2.1.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (226.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pgpack_dumper-0.2.1.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (226.0 kB view details)

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

pgpack_dumper-0.2.1.2-cp311-cp311-macosx_11_0_arm64.whl (49.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.2.1.2-cp311-cp311-macosx_10_14_x86_64.whl (48.2 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.2.1.2-cp310-cp310-win_amd64.whl (44.4 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.2.1.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (212.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

pgpack_dumper-0.2.1.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (211.6 kB view details)

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

pgpack_dumper-0.2.1.2-cp310-cp310-macosx_11_0_arm64.whl (48.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.2.1.2-cp310-cp310-macosx_10_14_x86_64.whl (47.6 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

Details for the file pgpack_dumper-0.2.1.2.tar.gz.

File metadata

  • Download URL: pgpack_dumper-0.2.1.2.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pgpack_dumper-0.2.1.2.tar.gz
Algorithm Hash digest
SHA256 ea5001cc8849b0093ac16ed6d5aed82fa27eaf54f9daa415ec3874d280ba6619
MD5 181b0c0f436bc26e0e460b7dee6c4a1a
BLAKE2b-256 2124c5826f4092829af8f11816c70782c3db1a6b2c0db880d95400a0810efdb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2c5a9b3f89c3751e113fc4f25c676ec118e72177ae1b153ee6e4db04d7574e2a
MD5 aab63c409d11630090d312c44c892031
BLAKE2b-256 2b73a4e07bf1449a21ff36b543b582943c9f7c608588added80faca3685f0c9c

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c53243c165714ead6377b5a7b6be1f75a8ca5a5235582895247b5741c50da41a
MD5 c48c5db8d9070dde4b8c012f65b87fc3
BLAKE2b-256 2f13a5d8f072936d1630b258243f68633e3e3cb72dc0d28b7a6a1e5ae66e4106

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 915b6b9050ccb9858d3c5117b76517cde1d916b5a0d7d386b087945504076163
MD5 54447efe5ea79b96945c83b77e318b05
BLAKE2b-256 c66a2aff3cc9395e610d38151c0307200b2817285301f45abbc419aa4d3b82f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a268375ee15efe963db28ebe51ba3e35c262a4c767c78396f0d2a7b5d68c882
MD5 2a853db9356c4ce01ef32ef6116f5d8d
BLAKE2b-256 fd1a0d7e8dd24bc7decb6b8be4a181f5c7f4b7a061556740cf69a39f42f9cb01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8f618b18961de74972d7e7491168e8f78ee8e25ef3e194faa4258b9611e863ae
MD5 5c180c43246991045684091a6b74281b
BLAKE2b-256 2bd57a76c6a60812f0e2d0919d6716cc7ba592ee6db44cb1e7532145325acd73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3cdc873b3f09b70051ce1e563a11416657b63ead748840866fcb8c4c47ee75ac
MD5 41be93469640a1a6c77089066b88fdcd
BLAKE2b-256 c0624634d8636414c496eff7e6e5e7d53b0783a21423dd4b276af4d13b9944c6

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 11eb6b0a8326881e6d31d4dd07bf1800d3f615e6b5c21162c745d272ac56ebd7
MD5 3de9979dab022acae6013451385e6865
BLAKE2b-256 fd34f3b88282c5fef4778f71e34e1083af24bce92d7223278e5d75c38b660bc2

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a78137ec0e94436391664f6eae7eff95e08656ecef5e96c3c32813be59e10337
MD5 c1ca4542ebe5dac3bc2582eee9b8c781
BLAKE2b-256 f451dd6faeef63223241e770218eb921ffd3e4a6da040e343e00aa2a4119bb6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c1d2e0952a025e66d4551f5f051e0f12b3909a026e5e1a1dec046f9e093cffe
MD5 4f44e0abe9fea12ca7544fdef919c558
BLAKE2b-256 1ff0074d0df794060e055fedd0530adc432ff37d2d253cd22d463283cc7bda69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 83dd8cdafd1c9849bc7a016162c01380e74c9b1a28788a35d5ddc8f04f2bb98b
MD5 6dfe84ce4843d4495806d88522457b48
BLAKE2b-256 f341d3af1befc603ca4f6088be2170be6097a301af01c6dca5f98e968cb3129b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c2e45c42b0bc48cef95ddd543cfa52e41848cf7f3fc15bb5a63dc6663f41e6e7
MD5 fa8817adc794e9c45f267b1b264f7d59
BLAKE2b-256 62108f68538c11efbb853b71ca5615c58707e0fbda944727db55128bf0f52df5

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7c79d8ad0c0ff3792cb873de005a8884e4a31c5dc089010dbe94bc5778fd7930
MD5 83b0ea61b3e8e9a1b282151f9ea1b0c6
BLAKE2b-256 8401519e3c3f5c6f61a3ae24735eca66613bf07a8084d5ed0f61f69dd138dfbd

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5bc9b3dc9caf02b926f895c5ff08942b666840f4787fd44012e2f86d4534deea
MD5 42af108199f04ac8a9ed1ee8b1c2fa7a
BLAKE2b-256 52411314d8f5a735ea7532fe44cd611c3a348975294c08ec8b67cf69709999df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c551c9920f107e2580ede456f2634ff1e525e85dbedf76a6aeca8b18f4a0bc2a
MD5 8b1d2e58b448403715fd20ec10858225
BLAKE2b-256 dd3e03a9b3ec0dcde6e0adb4ff56540c11725f5747b546cb7ac9be96eba2f82b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 21d6dbdc645d0f3a14875b5ef9a8dc52e6440835fb7a11dd151d69be874b3955
MD5 e8e071e9e7b00d09ac23a4445b08030f
BLAKE2b-256 eaca8131f3c117bfe9462bf9621909e739af0acc9b2101c7350ada0020f1bf55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fd18d74f573f351cdfbb34d83be79a42484c1d1c16b5b9186661cb559da79416
MD5 7797af047f29a7816a1a13d3946bf790
BLAKE2b-256 bb139700982b8c7ad5ad0c08b0b44c0a28677a5d2f6cf9f6b3b85232e56dcf6e

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 494460830a0b0cf970539e1bc7d35f04537898b05209f289b712dc3717a73c29
MD5 bcfbab69441de29baae39d4de674678f
BLAKE2b-256 47c05d61c7eaebdcb84db438fddda0def0f426bd51b001f4a5d1eeb2f4e03514

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 7a50bdb88e63a9aed7d6c2f34d8c76f6eee6eb2ad44a3e91bf359720454e2721
MD5 a60fa2aef2bc29f82a07522c98b30b86
BLAKE2b-256 44cb943ab24a128c780e6c78cefc55b50b51f2d076dcd8b4bbccedb0185280c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1d844350eb0ae0f80b040285e9444b0e6a350429bf9058c5095446425faa938
MD5 334f030b7dd6933b02cc7824e6c0509a
BLAKE2b-256 8eb6832f8cf573a8b1acb42a7f2e4d2b56b31eedb0888ad149105a4cc569fe0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 5514800efa9c2719f6346729b51078249ca614f8fd090ba492b4a7d4404e2587
MD5 ab55c025af83a6c4df00b1257e784ace
BLAKE2b-256 4391a2bbc83d850f011a447a8e870ed8c2d31d26c3569ebe5029cf9c340244f3

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