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.
Metadata
Release files for beam-postgres-connector 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| beam_postgres_connector-0.1.3.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beam_postgres_connector-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / beam_postgres_connector-0.1.3.tar.gz
| Download URL | beam_postgres_connector-0.1.3.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
031165e742f40f222ed1470257557dab85c9906fccd6574517e9f6e88f63f540
|
|
BLAKE2b-256 checksum How to use checksums |
30b35c5fb3adbb072daeb31214b32d2ae0f47336111f0e24a39d0a239533d898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.8.10 Linux/5.15.90.1-microsoft-standard-WSL2
|
Release files / beam_postgres_connector-0.1.3-py3-none-any.whl
| Download URL | beam_postgres_connector-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7fa78f34506d156d20d6b67c26ac67d8f89693d0b0e5de33ddf5c8a0ea5813ee
|
|
BLAKE2b-256 checksum How to use checksums |
a34f53218c636491005698cad0b9ef18eb6230704cf8c65d76c2e065190aeaf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.8.10 Linux/5.15.90.1-microsoft-standard-WSL2
|