Skip to main content

An io connector for PostgreSQL read/write in Apache Beam pipelines.

Project description

Beam - Postgres connector

PyPI Supported Versions License: MIT

Beam - Postgres Connector provides an io connector for PostgreSQL read/write in Apache Beam pipelines.

Installation

pip install beam-postgres-connector

Usage

  • Read From PostgreSQL
import apache_beam as beam
from beam_postgres import splitters
from beam_postgres.io import ReadFromPostgres

with beam.Pipeline(options=options) as p:
    read_from_postgres = ReadFromPostgres(
            query="SELECT * FROM test_db.test.test;",
            host="localhost",
            database="test_db",
            user="test",
            password="test",
            port=5432,
            splitter=splitters.NoSplitter()  # you can select how to split query for performance
    )


    (
        p
        | "ReadFromPostgres" >> read_from_postgres
        | "WriteToStdout" >> beam.Map(print)
    )
  • Write To Postgres
import apache_beam as beam
from beam_postgres.io import WriteToPostgres


with beam.Pipeline(options=options) as p:
    write_to_postgres = WriteToPostgres(
            host="localhost",
            database="test_db",
            table="test.test",
            user="test",
            password="test",
            port=5432,
            batch_size=1000,
    )

    (
        p
        | "ReadFromInMemory"
        >> beam.Create(
            [
                {
                    "name": "test data",
                }
            ]
        )
        | "WriteToPostgres" >> write_to_postgres
    )

See here for more examples.

splitters

  • NoSplitter

    Do not split the query

  • QuerySplitter

    Split the query by a specified separator string and distribute it for parallel processing across multiple nodes. Specify non-overlapping ranges for each query in the WHERE clause. The processing results will be combined using UNION ALL.

License

MIT License.

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

beam_postgres_connector-0.1.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

beam_postgres_connector-0.1.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file beam_postgres_connector-0.1.2.tar.gz.

File metadata

  • Download URL: beam_postgres_connector-0.1.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.16 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for beam_postgres_connector-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2356ca6ae2d60770d611d855f84554959dc0948584958b71c289b51bebb3f3a1
MD5 b9ea4f4abdde7d35f6bc737c30f92d4c
BLAKE2b-256 a2157cc53f2b81025cda0e4e6de9e0b657164dc7a1ebec5360ec0af86938fe9c

See more details on using hashes here.

File details

Details for the file beam_postgres_connector-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for beam_postgres_connector-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9342ba1c648934721adf0456bb1c79dc327581901e1ab33cd5e060f979f02344
MD5 d111f0a8cd37a7db70904e3156e6361a
BLAKE2b-256 74752a5721a0eac0026a7c6f652c169f8e8fad4fb69d5331f679ab6fe1ba3bc0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page