An io connector for PostgreSQL read/write in Apache Beam pipelines.
Project description
Beam - Postgres connector
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
031165e742f40f222ed1470257557dab85c9906fccd6574517e9f6e88f63f540
|
|
| MD5 |
6a030e641b568fed2a81f1c56a85182c
|
|
| BLAKE2b-256 |
30b35c5fb3adbb072daeb31214b32d2ae0f47336111f0e24a39d0a239533d898
|
File details
Details for the file beam_postgres_connector-0.1.3-py3-none-any.whl.
File metadata
- Download URL: beam_postgres_connector-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fa78f34506d156d20d6b67c26ac67d8f89693d0b0e5de33ddf5c8a0ea5813ee
|
|
| MD5 |
5950f51ad076f2607c923abecf135432
|
|
| BLAKE2b-256 |
a34f53218c636491005698cad0b9ef18eb6230704cf8c65d76c2e065190aeaf9
|