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.LZ4,  # or CompressionMethod.ZSTD or CompressionMethod.NONE
)

Read dump from PostgreSQL into file

file_name = "pgpack.lz4"
# 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 = "pgpack.lz4"
# 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.cursor,
)

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.1.2.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

pgpack_dumper-0.1.2.2-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pgpack_dumper-0.1.2.2.tar.gz
  • Upload date:
  • Size: 9.3 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.1.2.2.tar.gz
Algorithm Hash digest
SHA256 4a0f65c3ad986130b251be8f244e811436bfeef4d241bfeb973f3ed13f4ceb67
MD5 65f8c299fbbd297933dab6e6a80953b9
BLAKE2b-256 62ac80d1ff06b311cbb6f13e791b5a2eb78988c577bdf8c84259e25b9c8ee1d1

See more details on using hashes here.

File details

Details for the file pgpack_dumper-0.1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pgpack_dumper-0.1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e568384cb062de700dcbcdde70e1ac291e7a9c7f878e13deb0b0b5052c723c6a
MD5 0e487477b247185d4d808c36ce17421c
BLAKE2b-256 95e8c6ebe1f496b8ba219c282535d122082cd1de047bcd95f8c2fb0f9b356629

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