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 MySQL
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.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

beam_postgres_connector-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: beam_postgres_connector-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.7.16 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for beam_postgres_connector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c82861aa325c02a6020882b51a0b0a9ad4d51dd898c7d863472fdc398c3a115
MD5 6c76acd0c97c2668000cafb296f8b351
BLAKE2b-256 59d0e774fa3625fc1815c49966bbd1c80dd4f16d00f78c7d26fc8257ef60b28f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for beam_postgres_connector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 740d25cf7ad9941c4febc3eea52515f92d86988e0712ffdaefc12cf4a07ecb91
MD5 bbae7b927e3ee21b2f48722f97ac294c
BLAKE2b-256 81e344d99ee467b83b5990dfd8568c74f04a123be744b9d3089f133dbcc1b087

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