Metadata-Version: 2.2
Name: pg-channel
Version: 0.0.5
Summary: Generates PL/pgSQL script creating LISTEN/NOTIFY channels
Author-email: Mike Artemiev <mixartemev@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/XyncNet/pg-channel
Project-URL: Repository, https://github.com/XyncNet/pg-channel
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: setuptools_scm; extra == "dev"

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

# Postgres channels
Generates PL/pgSQL script creating LISTEN/NOTIFY channels from just table name and dict of update triggers with fields sets.

Function `plsql` takes one requiered `:str` arg - table_name, and generates PL/pgSQL script for creating 3 channels for 3 type events:

### Examples
###### On table: Fire `tables_new`: on create entity in `table`, `tables_del`: on delete entity from `table`, and `tables_upd`: on update any `table.field`:
```python
plsql('table')
```

And second optional `:dict` arg - dict of `list/tuples` of specified fields for triggering update event(s):
###### Set exactly field for triggering event: Fire `tables_upd_event1`: on update `table.field1`:
```python
plsql('table', 7, {'event1': ['field1']})
```

###### AND/OR conditions: Fire `tables_upd_event1`: on update `field1 AND field2`, and `tables_upd_event2`: on update `field2 OR field3`:
```python
{'event1': ('field1','field2'), 5, '_event2': ['field2', 'field3']}
```
