beam-postgres-0.3.2
توضیحات
Light IO transforms for Postgres read/write in Apache Beam pipelines.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX :: Linux |
| نام فایل | beam-postgres-0.3.2 |
| نام | beam-postgres |
| نسخه کتابخانه | 0.3.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Adam Medziński |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/beam-postgres/ |
| مجوز | Apache-2.0 |
# beam-postgres
[][pypi-project]
[][pypi-project]
Light IO transforms for Postgres read/write in Apache Beam pipelines.
## Goal
The project aims to provide highly performant and customizable transforms and is
not intended to support many different SQL database engines.
## Features
- `ReadAllFromPostgres` and `WriteToPostgres` transforms
- Records can be mapped to tuples, dictionaries or dataclasses
- Writes are in configurable batches
## Usage
Printing data from the database table:
```python
import apache_beam as beam
from psycopg.rows import dict_row
from beam_postgres.io import ReadAllFromPostgres
with beam.Pipeline() as p:
data = p | "Reading example records from database" >> ReadAllFromPostgres(
"host=localhost dbname=examples user=postgres password=postgres",
"select id, data from source",
dict_row,
)
data | "Writing to stdout" >> beam.Map(print)
```
Writing data to the database table:
```python
from dataclasses import dataclass
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions
from beam_postgres.io import WriteToPostgres
@dataclass
class Example:
data: str
with beam.Pipeline(options=PipelineOptions()) as p:
data = p | "Reading example records" >> beam.Create(
[
Example("example1"),
Example("example2"),
]
)
data | "Writing example records to database" >> WriteToPostgres(
"host=localhost dbname=examples user=postgres password=postgres",
"insert into sink (data) values (%s)",
)
```
See [here][examples] for more examples.
[pypi-project]: https://pypi.org/project/beam-postgres
[examples]: https://github.com/medzin/beam-postgres/tree/main/examples
نیازمندی
| مقدار | نام |
|---|---|
| <3,>=2.42.0 | apache-beam |
| <4,>=3.1.4 | psycopg[binary] |
| - | bumpver |
| - | pip-tools |
| - | tox |
| - | black |
| - | flake8 |
| - | isort |
| - | mypy |
| >=7 | pytest |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.9 | Python |
نحوه نصب
نصب پکیج whl beam-postgres-0.3.2:
pip install beam-postgres-0.3.2.whl
نصب پکیج tar.gz beam-postgres-0.3.2:
pip install beam-postgres-0.3.2.tar.gz