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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.5.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (217.8 kB view details)

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

pgpack_dumper-0.3.5.0-cp314-cp314-macosx_11_0_arm64.whl (53.2 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.5.0-cp314-cp314-macosx_10_15_x86_64.whl (52.3 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.5.0-cp313-cp313-win_amd64.whl (50.0 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.5.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (219.3 kB view details)

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

pgpack_dumper-0.3.5.0-cp313-cp313-macosx_11_0_arm64.whl (52.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.5.0-cp313-cp313-macosx_10_14_x86_64.whl (52.1 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.3.5.0-cp312-cp312-win_amd64.whl (50.2 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.5.0-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.5.0-cp312-cp312-macosx_11_0_arm64.whl (53.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.5.0-cp312-cp312-macosx_10_14_x86_64.whl (52.7 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.3.5.0-cp311-cp311-win_amd64.whl (50.2 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.5.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (222.7 kB view details)

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

pgpack_dumper-0.3.5.0-cp311-cp311-macosx_11_0_arm64.whl (53.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.5.0-cp311-cp311-macosx_10_14_x86_64.whl (52.7 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.3.5.0-cp310-cp310-win_amd64.whl (50.1 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.5.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (208.4 kB view details)

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

pgpack_dumper-0.3.5.0-cp310-cp310-macosx_11_0_arm64.whl (53.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.5.0-cp310-cp310-macosx_10_14_x86_64.whl (52.8 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3062706272c5c058745b4c3838dcd1559e92cef9746cb5cb28f6707aedd9b2a3
MD5 87f56da37d9eb5cbb617e5ea2a81abf3
BLAKE2b-256 514895edc991650b1f6cff78da2311b82c0258e05be618e5443266ba8b6b9798

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.0-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.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ce359fad6163f0a2faf5010649f8341d9703721c8936623392eec1a2f44e6d30
MD5 9a07e43c6d87efd04f1b5f4be380fa3a
BLAKE2b-256 7cb92a8206cbe0c3a6e00ab53918baf991242fa0d329e2d21c5566cb222adf28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bae166032050cf7f115a5f14cfb476502f35dcb7621d4f2b26db8a62dd24909
MD5 f7335e35e8d7fe882a81bccf8ef1cd55
BLAKE2b-256 0b80108e2fa95bc9c0dca064f246b2e28e200aff764297e402f19812a137bb56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 42cb294938d7a09d0690685725c9539d7bc009f921bb2f9a3d1e59dceaf4025f
MD5 7a01d1e51b69146bf0e83cfac48c79fe
BLAKE2b-256 053bc8b6cf4824675cb312f5444ee5a0e3395922054b9f58a6daecc596ce8fdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 28f395dcb54ee1d21b6cf4ede5842abfa2556c9eb3bdfb939cd4c2433a918f0d
MD5 a8585e50835221959a1f8aedb7a1e323
BLAKE2b-256 066d753632bb7de331b7a589f3450e44224b6ee0c04721794b6513c4ec56170d

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.0-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.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 50e531c38f8477e228a021d2bed05cf70bff7f6d1d988ce1d1fffe2b71695326
MD5 22409f9e146d38458bd87245d0d0c2a7
BLAKE2b-256 056f203018c2f0f1da8c4ab78fc4f19382a0e7559a708bb2cb0bb3bb15f1355c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dae1f46617ae47059125809745a0bc08c00492e022b222e164d6149c4d85bf47
MD5 6a15f2a423a5dca2454c584cf3ebb3df
BLAKE2b-256 590f975e6a0e0335b15144a6f19739bd7ac3c853bee3dae3d68effc41c24f7b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c6bd0412502341aabb52ebc105aee7d471aa9753d8806f5172f56da403e58228
MD5 7ef7f71b2270c30ccd1dde30e42e751c
BLAKE2b-256 659654a293e40da17b6ef10261b53053d63b3e590abc928a1a9da345d9db9b99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a59e9eea8c14330d7f5b7b0d99fe5a1edccf9a5aee27f768a0a4d534169959fe
MD5 68303a553fbd6bc60a03a7bc70528c19
BLAKE2b-256 43f10626214cb69bddf98a282e4926f4bafb7fc2c3b1e176b99c4f5b9ecfd8c2

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.0-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.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 79b781b9f69e66dbf28285796d7f8aa458fd861a16dba6bf54c404a3e9ac3a78
MD5 a5cbfd952abad2b0bd26f287e1ba6e1a
BLAKE2b-256 9b0d51255c56c0aae8c860ac3290980e2befed33ae5a37d8290d8e516c2ae3d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 098fdd261d3c11e8782873971e36970d1642645f2a202a9a2daf4efbcdf3b28a
MD5 2de5cf6a573bb60730a5754d68d1fb51
BLAKE2b-256 79d38437b2ace0d432007f29d9b656a6990ad2df2f64f41b8306e7d8d358c6e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 89da4b0137fde1c88ae0b898fee5779d0e5e89e47d1bc7afc8185669e85c44bb
MD5 add7fa12d3d937300292d0c2bf71b2bf
BLAKE2b-256 a22ac04e3dd93a816eac118035d8364cdae229dda3efcd473267bf8640de0afd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1aecab757d403f69a3abeda539669187e820dc4cebdd048ef465c55082d87418
MD5 467dbcfed141e293cd46d7d98ed11e28
BLAKE2b-256 ff1081faf0377778f96d8ce6d51757e56578466221421898b805886bdeeeed43

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.0-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.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5bcfdce4fabc42929c643d9066c2275f1e4d29ff6f7c23677f045f407c270c44
MD5 67e07a4ded31cab04d17815452a148ff
BLAKE2b-256 f6aab8564875bff5630d650260870421bca813737cc7666dc73cdaabf500407e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d775de8b0a060108189f4303d662ee12ac7c1f635c18d69b08577ee152390fb9
MD5 53d709fb6630605624ea358e9413da2d
BLAKE2b-256 4c962b5e28e5a177b6960299e928f681dba85408b7b6c136a061149e15187309

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 546333f2c046d2c303441db7f395fd62a8bc5b93f9ec5c644a89671328634c8e
MD5 2c385c54f8fa55ae840f363b04133647
BLAKE2b-256 6b44cf4456e9e8db10d230f9b0e8007c376ae921c8aea2560515bca9821f5dcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 516e32f1e78f85d2c976f236cec621d036f68611b05d5df5fd9be36e20e135c5
MD5 967775441ee8fb7392c2886da0854e53
BLAKE2b-256 1d296fc6b9271683b497acec8d7ff83638a6ad0f62ce71be77bdd52b885fcb32

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.5.0-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.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6def6c6ed1413917a2620f3eb16c15faaaabe41157f1528173cec55cfc9b6b65
MD5 a723d4f03ee460b1342e57e8a1460bf6
BLAKE2b-256 87efa344c00741f06c5130a0f2bcefcc1e76ad4e3728931a2000acf2f8ad4ca8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 51b9bc092f739a25ea86268fb8ec44f6e110e2dd4da4113d27f8f322f83a1413
MD5 1d521d14f5398f1720a55428875d1d26
BLAKE2b-256 7769e7193af94a4d0eab6beed0a35d3ad9ca93f21bce8b34786a62d9540210c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.5.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 134b987365aa414cb2db75511f38c0993dbb4b348c1bfd4713ba6be5d568faa4
MD5 5e41939e2f6bb4b1b40fbdbee542bb22
BLAKE2b-256 efe050d8f59dbb2399fefd648780323de81329385d31d83c903d04fdcc295c38

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