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.1.tar.gz (14.0 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.1-cp313-cp313-win_amd64.whl (43.5 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.2.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (220.2 kB view details)

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

pgpack_dumper-0.2.1.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (221.6 kB view details)

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

pgpack_dumper-0.2.1.1-cp313-cp313-macosx_11_0_arm64.whl (47.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.2.1.1-cp313-cp313-macosx_10_14_x86_64.whl (46.8 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.2.1.1-cp312-cp312-win_amd64.whl (43.8 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.2.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (233.3 kB view details)

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

pgpack_dumper-0.2.1.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (235.1 kB view details)

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

pgpack_dumper-0.2.1.1-cp312-cp312-macosx_11_0_arm64.whl (48.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.2.1.1-cp312-cp312-macosx_10_14_x86_64.whl (47.5 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.2.1.1-cp311-cp311-win_amd64.whl (43.8 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.2.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (225.5 kB view details)

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

pgpack_dumper-0.2.1.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (225.3 kB view details)

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

pgpack_dumper-0.2.1.1-cp311-cp311-macosx_11_0_arm64.whl (48.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.2.1.1-cp311-cp311-macosx_10_14_x86_64.whl (47.5 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.2.1.1-cp310-cp310-win_amd64.whl (43.7 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.2.1.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (211.8 kB view details)

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

pgpack_dumper-0.2.1.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (210.9 kB view details)

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

pgpack_dumper-0.2.1.1-cp310-cp310-macosx_11_0_arm64.whl (48.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.2.1.1-cp310-cp310-macosx_10_14_x86_64.whl (46.9 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: pgpack_dumper-0.2.1.1.tar.gz
  • Upload date:
  • Size: 14.0 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.1.tar.gz
Algorithm Hash digest
SHA256 c7c58e8af11e21f219b14d82e36795fde464423f9b332bc281d5f90eaec3e37f
MD5 712dc4329fccadd51d68bf0bedcdbdff
BLAKE2b-256 a60cc7cde4a9794da791f81db1e548d5cebe5bd47241c732aaf6d60e8c839309

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3d39b3b7de6f987fd8f5314846deec8e18cd5e7952534bd53e28645b3349837c
MD5 6ff83ba4bc954249c45fd89b892df67f
BLAKE2b-256 178636f6bb14a0ecb892798edb1a2a3073e9a6d4fcc344bb10dadc7d6774b04c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d53badb438f35cab57ff7d3a7e4d05f4b799093e8c18410ec1142dcf6e83cff5
MD5 50ffd6a0140759078a0592c00aeb3282
BLAKE2b-256 ec8cbb228a6e693dd660e94616cebd4c4ceb2c8cb1f07e6c6eed6bc638a7a190

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9726049de1ca7f795573b7f2c67c7adc7339f15278356518ed7e755dbe535545
MD5 abb01569de0ee90b6fd9e7b35edff2cd
BLAKE2b-256 efa4a885e39c246c3d84607c716edbd38887c5e0a69734a29fc8dfa1a3764724

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9544aedb6254213c85f2de91aab504009eab393129d269f567093ce26d0074e8
MD5 383b821dbc9f2a4a7acc1bb623e9f1c7
BLAKE2b-256 8843b7a1ea7a8952a8bffc933b7d2d1fedaaee10816031a7c77b10571230f329

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c934a8b2305b24576ff69cdd55dfc9d5cb582ff0c7305b481e280f1ff6d702aa
MD5 0abdf8c17dde1f33adb93bd1da14abf9
BLAKE2b-256 eb82d7080b2ffec2df525dcd50a811d557a35f63784a1a3da9f869c114315dec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b38c8200f42e648ee0da7402df84579e0c287e02c18e0ce7dca4ffa95e215d90
MD5 475782638cc2ab85a10b976c74f55028
BLAKE2b-256 96727c9e01081336bc0232ababa4ff58d4f08e3688c4db81ebcab2aaad8ea710

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bc4256c13ed91f7a3d9c60a8a6fcd60c521bbbba8af74ecfff6564fe62917561
MD5 8df3921d6d740e1f2588a8d300e88c58
BLAKE2b-256 3d5d5284b8c493710a806046dcf4410dba3d461f320db9a6d835292fe611ebaa

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5768858d4a33718ee1dcebedb47428280170a8772ed16cbca8ddb66cb212173b
MD5 f040685a0de748520c1ee33d67c02858
BLAKE2b-256 41b7876f155a603982a2299d9dc33bde85870eec5a41c0547dc74c62461b4c76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72cc6b5c93132c76f8ee8ede09268c5cfab2c7923816c5d5452513e1a72de4f1
MD5 ba1f8c068542da283fc4fe8870f022a8
BLAKE2b-256 8059cfa0f139b43fb3c5b4e91addd3dbb6435bb398d27900972f15b509a9a042

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 033aa762009d1f9344c469108b8bf224668d7dc23482defdeb17ca5f00d9e3f3
MD5 7c278f72503c1ec88cae1086091ab4a9
BLAKE2b-256 d291d937b95e5c00d74ce784b5c2b2b06a6ceb689c84a98414abcaa9f77e1250

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6ecba32963584a65ef822e26e4a5f056ab251e029b50fbe18886f3f076ea3190
MD5 da8ed6da3d6c1235c2f3c69e68362ba6
BLAKE2b-256 951125b3c8251d74c47b0ce5be250077b22a47929d08b3d151c77f22b9122fc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 78a5540bb3b953714a050bc578611edb0162c8bd9492da62dee26aafe145db58
MD5 30d2c6bf9cccfbb896e1e3365061c6ae
BLAKE2b-256 193581f0984195b072f58fded5069127c78cce066e6450ed4dab896dc5b16d84

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 13a7dbee32dcd02d218438fac4b123396f5304e24a3908e89765beb7bc3a2e55
MD5 31b30353cd1719aa6cdabe776b7c12d6
BLAKE2b-256 6b131b38cc544799ed51722c49faa61106b677beff725e2b851127adf1417618

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a2e25dc4d4c09517f04e3a46c0075137b5fe246ec781d319b754bb01f63915c
MD5 af6b6a87be3a7a5d51f182cd75a5a38a
BLAKE2b-256 46556da4bb6bfef67df6cdd1076105423fa8bb3cd631cb5749a715324fdfa7b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 084441ed5182be030846d3b7afefa0fbbcecb307000422d50fe95a9464ec8618
MD5 5add0ea6ffe4ec73784cbb24d938f25e
BLAKE2b-256 5db1fe5ec2008a8b442cc46c15e028442243301e267ac383cd4ce87e078f5de7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3441800a3929cc0ec668113f4c8c95e8de9c6e1580db704eb2bc0e8be0f32264
MD5 ed0b9de4be99b2e41dab159c05699caf
BLAKE2b-256 c060299e875021d74ec73c1b7dd52ef1da40aabe0f71b13a59be9fc3d1e21f9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 525f6afa08b91c78277bb2a9080f2e3ff0300a0b9cde56e726f977e603610084
MD5 ac5a961eec036a938042e4298323b879
BLAKE2b-256 b2c6a7d797445f1435ace6609b190a23cc481b01074cd9325a8c236c14166d24

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.2.1.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.2.1.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6e42ecb339cb1c241ed57aa7c0f1edecf87a950ef13dba63e9479fb500f23797
MD5 173920c995d67de83ce1f39ed93bb7e3
BLAKE2b-256 c5ce053f2503026b29e06b5120aa714f48d545199360c4fc8bd9419bc76494a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b50a02e41e7affc8452f6ed31df6fe07d853323902cb0cf38a6803795ff74578
MD5 482b0b52badcad799b42e417c84cf56d
BLAKE2b-256 de59573fcef8e48dd8351a027801a97ec26b79d55d43cfdd68d965fab4e49807

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.2.1.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f5f26ee76e5ec8f73d48608db8aad6a8e640479c0ee54c554bdc4462c44e6ebc
MD5 39f08b3501843bb9de4576d62246318c
BLAKE2b-256 4425088dc2b578f36fbe39aafc8ecb5ee42ac5ebb1a133e657213b948d8cedeb

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