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

Uploaded CPython 3.14Windows x86-64

pgpack_dumper-0.3.4.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (214.5 kB view details)

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

pgpack_dumper-0.3.4.1-cp314-cp314-macosx_11_0_arm64.whl (49.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pgpack_dumper-0.3.4.1-cp314-cp314-macosx_10_15_x86_64.whl (48.8 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

pgpack_dumper-0.3.4.1-cp313-cp313-win_amd64.whl (46.5 kB view details)

Uploaded CPython 3.13Windows x86-64

pgpack_dumper-0.3.4.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (216.2 kB view details)

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

pgpack_dumper-0.3.4.1-cp313-cp313-macosx_11_0_arm64.whl (49.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pgpack_dumper-0.3.4.1-cp313-cp313-macosx_10_14_x86_64.whl (48.6 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

pgpack_dumper-0.3.4.1-cp312-cp312-win_amd64.whl (46.7 kB view details)

Uploaded CPython 3.12Windows x86-64

pgpack_dumper-0.3.4.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (228.5 kB view details)

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

pgpack_dumper-0.3.4.1-cp312-cp312-macosx_11_0_arm64.whl (49.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pgpack_dumper-0.3.4.1-cp312-cp312-macosx_10_14_x86_64.whl (49.2 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

pgpack_dumper-0.3.4.1-cp311-cp311-win_amd64.whl (46.6 kB view details)

Uploaded CPython 3.11Windows x86-64

pgpack_dumper-0.3.4.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (219.3 kB view details)

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

pgpack_dumper-0.3.4.1-cp311-cp311-macosx_11_0_arm64.whl (50.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pgpack_dumper-0.3.4.1-cp311-cp311-macosx_10_14_x86_64.whl (49.2 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

pgpack_dumper-0.3.4.1-cp310-cp310-win_amd64.whl (46.6 kB view details)

Uploaded CPython 3.10Windows x86-64

pgpack_dumper-0.3.4.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (205.4 kB view details)

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

pgpack_dumper-0.3.4.1-cp310-cp310-macosx_11_0_arm64.whl (50.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pgpack_dumper-0.3.4.1-cp310-cp310-macosx_10_14_x86_64.whl (49.3 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 f11ac85d2046ebebd0dbc6ec9576c990fb5bafe2922c58c6764be6247e7e2eaf
MD5 6bac0c0c03d349738c6eb022bd19f4e4
BLAKE2b-256 c29948269d7ac9a1958e08d1dd47ed103b3734642f389d3637a2ceaa05f7227a

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.1-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.4.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5d04fe0ef2e7eb18f763b83594a1cba46a56712ca03939fff6829fdf3e2482c2
MD5 34dda267db9353227b6bdf53c4f0aacd
BLAKE2b-256 6c7aa4fc7983935baf1730785a0d9396d5b1c35e15ffe5ba94cbb06de7669649

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92852b3b865917d9e28cc40e3d50fa1c3608fbcfe1d837540e1d72838ff45950
MD5 0388f4386ff6a51e3386faf9a858837d
BLAKE2b-256 e83291b1c5f808e1c9ee22cdbac38e40dba995fde988d85277581846b00ff758

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 fcdb12ae6ddfd11dffd66aca2054e199d53bb30eb277a0b63182baaba752c6e9
MD5 f47b125d409836b703d6fd1b83367c64
BLAKE2b-256 2c472bd82b2d9d67e92201eebefc3c29f108a92ed397128639cdb2575f498deb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f394a4ebd73a8c2b642bab69202b2f944da2666f495d01c242c6f5ef73d6dec1
MD5 9c2d72176164f7f5669cdc40c240f441
BLAKE2b-256 1be33b1c34f574e08fed414af795bc52379970b00e7029e2538e5b5f198e4125

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.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.3.4.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0cfe7c7a8530f2e597b9fca6d8dc331478f3297f4df2d1fb04c6615f762f4da1
MD5 35efa734077bd379aa21644930388ecc
BLAKE2b-256 8031e9021cad3dc0d8388f0e0c7dad19579b91542dcd91d765026fed0d86bd59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7f6121958767e58ce20707257e2228f1479840caa6040b12de6295d210b6432a
MD5 22f9bddd340698ceebae8806da4b477c
BLAKE2b-256 9533e4a8ce949a3e8476aa14e9e92b7c73df45c4c9cafa5941b8233b26377f51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 3b9566bd0b3c6425ec5f56b960ea448ba2bac4875523c504e404c7effa5b421e
MD5 517e41ecb6d1ebb5fcf9f9c62a431c97
BLAKE2b-256 ea6163718b22287c04fe7ea0fe380c38a2a2219c82e93ed7cfaa03ad0136e989

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 454584ee3e659e53c2111db506918786c159a7b18f67ac204ca0aad8c28a9710
MD5 10489358474bb45ca1e8534ef6408b7a
BLAKE2b-256 a34a496a0fb8ef3e7881a104608707cd56a885822487a2676ec908376d2c609f

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.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.3.4.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f595168460944f4a33226219cfc181f2d62d974810269a9fb1cec67d097554a7
MD5 cef36e119ecbe2744568b28b3933ba10
BLAKE2b-256 7b437abb32e2df9e82146e97e1282631a4500beece4444b82445621c68f7b731

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d5b9e28093b19f94b382bee45537ba784180798d5180892bce91aa433bfcfca
MD5 e7043d3590378c0f28ec08e05b53bbb7
BLAKE2b-256 6e42ba5f8d6ac92d5748027e396064a62751cc1b1477b60fbf29f1e656e1ad40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 953fc2cdb940b6072aeace23d498300673a84c5924d55e303f403fef2119e594
MD5 bac7655bf4528ded7bdc3351b60eacfa
BLAKE2b-256 08deeb9b8c7946894a0c59febbfe50217a304426e5969037d12c9ec6b51b14fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 37acaba4fefbe59e50712f8d66a0d68dd53e0b6bfb7a4b785db9b65db280ebe4
MD5 dc51897a437a31e6649e91c57e5708b4
BLAKE2b-256 f94a45e2763fbe1352c63a232c5305cd2ad7a3a1c5894f1b39b13f57712ca717

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.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.3.4.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 06f843ef884a29ad8dbf65531a348ec80b2a5890dc19b0f29fb4f9632c98bf45
MD5 c35f0ab78f950fcafae9238482be3192
BLAKE2b-256 e3d452fe8b2b929a9d45f839e15def53820ac30141e5894856eb4242ee169b42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcbe89cbebc06b0364161018142e47686594bfd176908156ef1a810726596e30
MD5 d7beea9f046d16fd53c3a666831d20c3
BLAKE2b-256 3357f08fa28fa339efd5037d2c8df83a56bfcc5e6aedbd59a231e8d0cd11bb80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2adc246dda9432f59f9bc9b1e663eb01633e5f2daffd67df105e58b436f64338
MD5 b1d87ad5c9448eff3a156967d0d60c8d
BLAKE2b-256 02417572a33383b04b3484a8e881ef598109a042cdfb4441209c5c5134f1aa56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d8390c97e0d56bb6aff0f1a80317e4b9d109d0c462ced80f764b3029749b9c6a
MD5 4b2598e9de4a79a92161eca0dca53603
BLAKE2b-256 46ef4e9a88b2daa8427838edcc4f57f9f032169c9cd61a391935d25f1684c172

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.3.4.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.3.4.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 37de12d0909a56f48be858530f6b327694734aab95e58c1cd803c2468ed4fc7a
MD5 476fda6c00e6d6ca217401f1e47276d0
BLAKE2b-256 348835f904b2be0b71201432216bc023067ef36d3522da22d6c3127c99b57f9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e0e690796b031e873c6d9f9b81bb09e202ef0ed374193cfe57edb9cc505c4f1
MD5 b89005bf97a13cb115f72aef21302dfc
BLAKE2b-256 a362d05f11d28e0a70e3c9b87e82d97b20b44397bfeea8506ed76f11e6b1c124

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pgpack_dumper-0.3.4.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ff3ea50738751e855e54f4d79faaa85f7a19a01b797a10bd794f557fc3cc651b
MD5 cad8376bee65b7f8e96d7a0dac7b07fb
BLAKE2b-256 95f252b8233a15de57e11e0f93282087cd8b794b537e3888d46f578082db79fb

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