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

Uploaded Source

Built Distribution

beam_postgres_connector-0.1.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for beam_postgres_connector-0.1.3.tar.gz
Algorithm Hash digest
SHA256 031165e742f40f222ed1470257557dab85c9906fccd6574517e9f6e88f63f540
MD5 6a030e641b568fed2a81f1c56a85182c
BLAKE2b-256 30b35c5fb3adbb072daeb31214b32d2ae0f47336111f0e24a39d0a239533d898

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for beam_postgres_connector-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7fa78f34506d156d20d6b67c26ac67d8f89693d0b0e5de33ddf5c8a0ea5813ee
MD5 5950f51ad076f2607c923abecf135432
BLAKE2b-256 a34f53218c636491005698cad0b9ef18eb6230704cf8c65d76c2e065190aeaf9

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