pgpigeon


Namepgpigeon JSON
Version 1.1.5 PyPI version JSON
download
home_page
SummaryThis package help to implement realtime db notifications.
upload_time2023-05-30 13:43:11
maintainer
docs_urlNone
author
requires_python>=3.6
licenseMIT License Copyright (c) 2022 Dinesh Kushwaha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords python postgresql realtime notification pg_notify channel
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h3 align="center">PgPigeon</h3>

<p align="center"> This package will help to capture realtime postgreSQL table notification in python scripts.
    <br> 
</p>

## 📝 Table of Contents

- [📝 Table of Contents](#-table-of-contents)
- [🧐 About ](#-about-)
- [🏁 Getting Started ](#-getting-started-)
- [✍️ Authors ](#️-authors-)

## 🧐 About <a name = "about"></a>

This package can be used for capture PostgreSQL database table event at real time in python scripts.

## 🏁 Getting Started <a name = "getting_started"></a>
- Dependancy & prerequisite 
    - Python >=3.6 should be installed.
    - "psycopg2>=2.9.3"

- To Start experimenting this package you need to install it.

- [Step - 1]
```

    pip install pgpigeon

```

- [Step - 2]
    - To configure pigeon 
    ```

    pigeon configure

    ```
    This will create the configuration file "pigeon.json" in "pigeon" folder.
    In this file you can see database related settings i.e. database , schema , tables and triggers.

- [Step - 3] 
    - [To generate the db scripts i.e. triggers run following command ]
    ``` 

    pigeon create-scripts

    ```
    This will create all the required scripts in "pigeon/scripts" folder. 
    Two scripts files will be created on for trigger function and second trigger.

- [Step - 4]
    - To create the triggers in database i.e. run following command 
    ```


    pigeon create-triggers

    ```
    This will create required triggers in database. 
- [Step - 5]
    - To create sample code run following command 
    ```

    pigeon sample-code

    ```
    This will create sample code in "pigeon.py". 

Now you an hook "pigeon.py" sample code anywhere in your code logic.
It will start notifying if any change happen in the target db tables.


- Let's review "pigeon.json" configuration file. 

```
    {
    "dbname": "postgres",
    "host": "localhost",
    "port": "5432",
    "user": "postgres",
    "password": "postgres",
    "schemas": [
        {
            "name": "public",
            "tables": [
                {
                    "name": "items",
                    "triggers": [
                        {
                            "name": "pg_pigeon_default_after_insert_update_delete_trigger",
                            "trigger_func": "pg_pigeon_default_after_insert_update_delete_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "INSERT OR UPDATE OR DELETE",
                            "trigger_on_statement": "INSERT OR UPDATE OR DELETE",
                            "on_condition": "AFTER",
                            "is_active": "True"
                        },
                        {
                            "name": "pg_pigeon_default_before_insert_update_delete_trigger",
                            "trigger_func": "pg_pigeon_default_before_insert_update_delete_trigger_func",
                            "channel_name": "pg_pigeon_default_channel_before",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "INSERT OR UPDATE OR DELETE",
                            "trigger_on_statement": "INSERT OR UPDATE OR DELETE",
                            "on_condition": "BEFORE",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_after_insert_update_trigger",
                            "trigger_func": "pg_pigeon_default_after_insert_update_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "INSERT OR UPDATE OR DELETE",
                            "trigger_on_statement": "INSERT OR UPDATE OR DELETE",
                            "on_condition": "AFTER",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_after_insert_trigger",
                            "trigger_func": "pg_pigeon_default_after_insert_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "INSERT",
                            "trigger_on_statement": "INSERT",
                            "on_condition": "AFTER",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_after_update_trigger",
                            "trigger_func": "pg_pigeon_default_after_update_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "UPDATE",
                            "trigger_on_statement": "UPDATE OF item_description",
                            "on_condition": "AFTER",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_after_delete_trigger",
                            "trigger_func": "pg_pigeon_default_after_delete_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "DELETE",
                            "trigger_on_statement": "DELETE",
                            "on_condition": "AFTER",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_before_insert_trigger",
                            "trigger_func": "pg_pigeon_default_before_insert_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "INSERT",
                            "trigger_on_statement": "INSERT",
                            "on_condition": "BEFORE",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_before_update_trigger",
                            "trigger_func": "pg_pigeon_default_before_update_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "UPDATE",
                            "trigger_on_statement": "UPDATE OF item_no , item_description",
                            "on_condition": "BEFORE",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_instead_of_insert_trigger",
                            "trigger_func": "pg_pigeon_default_instead_of_insert_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "INSERT",
                            "trigger_on_statement": "INSERT",
                            "on_condition": "INSTEAD OF",
                            "is_active": "False"
                        },
                        {
                            "name": "pg_pigeon_default_instead_of_update_trigger",
                            "trigger_func": "pg_pigeon_default_instead_of_update_trigger_func",
                            "channel_name": "pg_pigeon_default_channel",
                            "return_columns": "['item_no', 'item_description']",
                            "type": "ROW",
                            "trigger_on": "UPDATE",
                            "trigger_on_statement": "UPDATE OF item_no , item_description",
                            "on_condition": "INSTEAD OF",
                            "is_active": "False"
                        }
                    ]
                }
            ]
        }
    ]
}
```

Now you can see above json config file having all the details in order to create trigger for notification.
i.e. database connection details for connectivity , schema , table and trigger info to create triggers.

Note - 
```

"channel_name": "pg_pigeon_default_channel"

```
"channel_name" is the property responsible to communicate with python script.

"return_columns" is the json property responsible to send notification payload to python script.
This property value should be look like below one.

```

"return_columns": "['item_no', 'item_description']"

```

For example - as mentioned in json config file.
if we have a table "items" structure like 

```
CREATE TABLE public.items (
	item_no int4 NULL,
	item_description varchar NULL
);

```
then this property should be look like 
```
"return_columns": "['item_no', 'item_description']"
```
all the keys are table column names.

Let's review the sample code .

```
from pgpigeon.pgnest import PgNest
from pgpigeon.context_models import PigeonChannelContext,PigeonContext, PgExecutionStrategy

class PGPigeonClient:
    def callback_func(self, channel, payload):
        print(f"Channel : {channel}")
        print(f"Payload : {payload}")

    def get_pg_db_dict(self):
        pg_db_dict = {}
        pg_db_dict["dbname"] = "postgres"
        pg_db_dict["host"] = "localhost"
        pg_db_dict["port"] = "5432"
        pg_db_dict["user"] = "postgres"
        pg_db_dict["password"] = "postgres"
        return pg_db_dict

    def start_keep_eye_on_channels_and_notify(self):
        pg_contexts = []

        pg_context = PigeonContext("pg_pigeon_default_process")
        pg_context.execution_strategy = PgExecutionStrategy.IN_SEPARATE_PROCESS
        # If you set is_main_on_hold=True , main thread or process will be blocked.
        # If you set is_main_on_hold=False , main thread or process will keep running.
        pg_context.is_main_on_hold = True

        pg_channel = PigeonChannelContext("pg_pigeon_default_channel")
        pg_channel.callbacks.append(self.callback_func)

        pg_context.channels.append(pg_channel)
        pg_contexts.append(pg_context)

        pg_nest = PgNest()
        pg_db_dict = self.get_pg_db_dict()
        pg_nest.start_keep_eye_on_channels_and_notify(
            pg_db_dict, pg_contexts)


if __name__ == "__main__":
    client = PGPigeonClient()
    client.start_keep_eye_on_channels_and_notify()
```

From above sample code you can see the python script is listening the channel for notification.
Once your script is successfully running you will see the logs.
```
:: Parent process id , name  : 23512:: Current process id , name  : 19768
:: Waiting for new messages payload ....
```

if you insert or update or delete any record in target db table you will see this logs.
```
:: Current process id , name  : 19768
:: Waiting for new messages payload ....
:: Message payload received from channel pg_pigeon_default_channel): {"item_no" : 1, "item_description" : "23523523", "action" : "INSERT"}
Channel : pg_pigeon_default_channel
Payload : {"item_no" : 1, "item_description" : "23523523", "action" : "INSERT"}
:: Parent process id , name  : 23512:: Current process id , name  : 19768
:: Waiting for new messages payload ....
:: Message payload received from channel pg_pigeon_default_channel): {"item_no" : 1, "item_description" : "dinesh kushwaha", "action" : "UPDATE"}
Channel : pg_pigeon_default_channel
Payload : {"item_no" : 1, "item_description" : "dinesh kushwaha", "action" : "UPDATE"}
:: Parent process id , name  : 23512:: Current process id , name  : 19768
:: Waiting for new messages payload ....
:: Message payload received from channel pg_pigeon_default_channel): {"item_no" : 1, "item_description" : "dinesh kushwaha", "action" : "DELETE"}
Channel : pg_pigeon_default_channel
Payload : {"item_no" : 1, "item_description" : "dinesh kushwaha", "action" : "DELETE"}
:: Parent process id , name  : 23512:: Current process id , name  : 19768
:: Waiting for new messages payload ....
```

Now you can dieselize the payload and you can do anything with it.

## ✍️ Authors <a name = "authors"></a>

- [Dinesh Kushwaha](https://pypi.org/user/dinesh-pypi/) - Idea & Initial work

See also the list of [contributors](https://github.com/dinesh-kushwaha) who participated in this project.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pgpigeon",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,postgresql,realtime,notification,pg_notify,channel",
    "author": "",
    "author_email": "Dinesh Kushwaha <2kush.dinesh@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/54/f9/10072bf9321f5308e0742f584d19cceeaec13bd73b01ee94da1bbfab99f9/pgpigeon-1.1.5.tar.gz",
    "platform": null,
    "description": "<h3 align=\"center\">PgPigeon</h3>\r\n\r\n<p align=\"center\"> This package will help to capture realtime postgreSQL table notification in python scripts.\r\n    <br> \r\n</p>\r\n\r\n## \ud83d\udcdd Table of Contents\r\n\r\n- [\ud83d\udcdd Table of Contents](#-table-of-contents)\r\n- [\ud83e\uddd0 About ](#-about-)\r\n- [\ud83c\udfc1 Getting Started ](#-getting-started-)\r\n- [\u270d\ufe0f Authors ](#\ufe0f-authors-)\r\n\r\n## \ud83e\uddd0 About <a name = \"about\"></a>\r\n\r\nThis package can be used for capture PostgreSQL database table event at real time in python scripts.\r\n\r\n## \ud83c\udfc1 Getting Started <a name = \"getting_started\"></a>\r\n- Dependancy & prerequisite \r\n    - Python >=3.6 should be installed.\r\n    - \"psycopg2>=2.9.3\"\r\n\r\n- To Start experimenting this package you need to install it.\r\n\r\n- [Step - 1]\r\n```\r\n\r\n    pip install pgpigeon\r\n\r\n```\r\n\r\n- [Step - 2]\r\n    - To configure pigeon \r\n    ```\r\n\r\n    pigeon configure\r\n\r\n    ```\r\n    This will create the configuration file \"pigeon.json\" in \"pigeon\" folder.\r\n    In this file you can see database related settings i.e. database , schema , tables and triggers.\r\n\r\n- [Step - 3] \r\n    - [To generate the db scripts i.e. triggers run following command ]\r\n    ``` \r\n\r\n    pigeon create-scripts\r\n\r\n    ```\r\n    This will create all the required scripts in \"pigeon/scripts\" folder. \r\n    Two scripts files will be created on for trigger function and second trigger.\r\n\r\n- [Step - 4]\r\n    - To create the triggers in database i.e. run following command \r\n    ```\r\n\r\n\r\n    pigeon create-triggers\r\n\r\n    ```\r\n    This will create required triggers in database. \r\n- [Step - 5]\r\n    - To create sample code run following command \r\n    ```\r\n\r\n    pigeon sample-code\r\n\r\n    ```\r\n    This will create sample code in \"pigeon.py\". \r\n\r\nNow you an hook \"pigeon.py\" sample code anywhere in your code logic.\r\nIt will start notifying if any change happen in the target db tables.\r\n\r\n\r\n- Let's review \"pigeon.json\" configuration file. \r\n\r\n```\r\n    {\r\n    \"dbname\": \"postgres\",\r\n    \"host\": \"localhost\",\r\n    \"port\": \"5432\",\r\n    \"user\": \"postgres\",\r\n    \"password\": \"postgres\",\r\n    \"schemas\": [\r\n        {\r\n            \"name\": \"public\",\r\n            \"tables\": [\r\n                {\r\n                    \"name\": \"items\",\r\n                    \"triggers\": [\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_after_insert_update_delete_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_after_insert_update_delete_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"INSERT OR UPDATE OR DELETE\",\r\n                            \"trigger_on_statement\": \"INSERT OR UPDATE OR DELETE\",\r\n                            \"on_condition\": \"AFTER\",\r\n                            \"is_active\": \"True\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_before_insert_update_delete_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_before_insert_update_delete_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel_before\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"INSERT OR UPDATE OR DELETE\",\r\n                            \"trigger_on_statement\": \"INSERT OR UPDATE OR DELETE\",\r\n                            \"on_condition\": \"BEFORE\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_after_insert_update_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_after_insert_update_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"INSERT OR UPDATE OR DELETE\",\r\n                            \"trigger_on_statement\": \"INSERT OR UPDATE OR DELETE\",\r\n                            \"on_condition\": \"AFTER\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_after_insert_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_after_insert_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"INSERT\",\r\n                            \"trigger_on_statement\": \"INSERT\",\r\n                            \"on_condition\": \"AFTER\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_after_update_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_after_update_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"UPDATE\",\r\n                            \"trigger_on_statement\": \"UPDATE OF item_description\",\r\n                            \"on_condition\": \"AFTER\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_after_delete_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_after_delete_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"DELETE\",\r\n                            \"trigger_on_statement\": \"DELETE\",\r\n                            \"on_condition\": \"AFTER\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_before_insert_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_before_insert_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"INSERT\",\r\n                            \"trigger_on_statement\": \"INSERT\",\r\n                            \"on_condition\": \"BEFORE\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_before_update_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_before_update_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"UPDATE\",\r\n                            \"trigger_on_statement\": \"UPDATE OF item_no , item_description\",\r\n                            \"on_condition\": \"BEFORE\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_instead_of_insert_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_instead_of_insert_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"INSERT\",\r\n                            \"trigger_on_statement\": \"INSERT\",\r\n                            \"on_condition\": \"INSTEAD OF\",\r\n                            \"is_active\": \"False\"\r\n                        },\r\n                        {\r\n                            \"name\": \"pg_pigeon_default_instead_of_update_trigger\",\r\n                            \"trigger_func\": \"pg_pigeon_default_instead_of_update_trigger_func\",\r\n                            \"channel_name\": \"pg_pigeon_default_channel\",\r\n                            \"return_columns\": \"['item_no', 'item_description']\",\r\n                            \"type\": \"ROW\",\r\n                            \"trigger_on\": \"UPDATE\",\r\n                            \"trigger_on_statement\": \"UPDATE OF item_no , item_description\",\r\n                            \"on_condition\": \"INSTEAD OF\",\r\n                            \"is_active\": \"False\"\r\n                        }\r\n                    ]\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nNow you can see above json config file having all the details in order to create trigger for notification.\r\ni.e. database connection details for connectivity , schema , table and trigger info to create triggers.\r\n\r\nNote - \r\n```\r\n\r\n\"channel_name\": \"pg_pigeon_default_channel\"\r\n\r\n```\r\n\"channel_name\" is the property responsible to communicate with python script.\r\n\r\n\"return_columns\" is the json property responsible to send notification payload to python script.\r\nThis property value should be look like below one.\r\n\r\n```\r\n\r\n\"return_columns\": \"['item_no', 'item_description']\"\r\n\r\n```\r\n\r\nFor example - as mentioned in json config file.\r\nif we have a table \"items\" structure like \r\n\r\n```\r\nCREATE TABLE public.items (\r\n\titem_no int4 NULL,\r\n\titem_description varchar NULL\r\n);\r\n\r\n```\r\nthen this property should be look like \r\n```\r\n\"return_columns\": \"['item_no', 'item_description']\"\r\n```\r\nall the keys are table column names.\r\n\r\nLet's review the sample code .\r\n\r\n```\r\nfrom pgpigeon.pgnest import PgNest\r\nfrom pgpigeon.context_models import PigeonChannelContext,PigeonContext, PgExecutionStrategy\r\n\r\nclass PGPigeonClient:\r\n    def callback_func(self, channel, payload):\r\n        print(f\"Channel : {channel}\")\r\n        print(f\"Payload : {payload}\")\r\n\r\n    def get_pg_db_dict(self):\r\n        pg_db_dict = {}\r\n        pg_db_dict[\"dbname\"] = \"postgres\"\r\n        pg_db_dict[\"host\"] = \"localhost\"\r\n        pg_db_dict[\"port\"] = \"5432\"\r\n        pg_db_dict[\"user\"] = \"postgres\"\r\n        pg_db_dict[\"password\"] = \"postgres\"\r\n        return pg_db_dict\r\n\r\n    def start_keep_eye_on_channels_and_notify(self):\r\n        pg_contexts = []\r\n\r\n        pg_context = PigeonContext(\"pg_pigeon_default_process\")\r\n        pg_context.execution_strategy = PgExecutionStrategy.IN_SEPARATE_PROCESS\r\n        # If you set is_main_on_hold=True , main thread or process will be blocked.\r\n        # If you set is_main_on_hold=False , main thread or process will keep running.\r\n        pg_context.is_main_on_hold = True\r\n\r\n        pg_channel = PigeonChannelContext(\"pg_pigeon_default_channel\")\r\n        pg_channel.callbacks.append(self.callback_func)\r\n\r\n        pg_context.channels.append(pg_channel)\r\n        pg_contexts.append(pg_context)\r\n\r\n        pg_nest = PgNest()\r\n        pg_db_dict = self.get_pg_db_dict()\r\n        pg_nest.start_keep_eye_on_channels_and_notify(\r\n            pg_db_dict, pg_contexts)\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    client = PGPigeonClient()\r\n    client.start_keep_eye_on_channels_and_notify()\r\n```\r\n\r\nFrom above sample code you can see the python script is listening the channel for notification.\r\nOnce your script is successfully running you will see the logs.\r\n```\r\n:: Parent process id , name  : 23512:: Current process id , name  : 19768\r\n:: Waiting for new messages payload ....\r\n```\r\n\r\nif you insert or update or delete any record in target db table you will see this logs.\r\n```\r\n:: Current process id , name  : 19768\r\n:: Waiting for new messages payload ....\r\n:: Message payload received from channel pg_pigeon_default_channel): {\"item_no\" : 1, \"item_description\" : \"23523523\", \"action\" : \"INSERT\"}\r\nChannel : pg_pigeon_default_channel\r\nPayload : {\"item_no\" : 1, \"item_description\" : \"23523523\", \"action\" : \"INSERT\"}\r\n:: Parent process id , name  : 23512:: Current process id , name  : 19768\r\n:: Waiting for new messages payload ....\r\n:: Message payload received from channel pg_pigeon_default_channel): {\"item_no\" : 1, \"item_description\" : \"dinesh kushwaha\", \"action\" : \"UPDATE\"}\r\nChannel : pg_pigeon_default_channel\r\nPayload : {\"item_no\" : 1, \"item_description\" : \"dinesh kushwaha\", \"action\" : \"UPDATE\"}\r\n:: Parent process id , name  : 23512:: Current process id , name  : 19768\r\n:: Waiting for new messages payload ....\r\n:: Message payload received from channel pg_pigeon_default_channel): {\"item_no\" : 1, \"item_description\" : \"dinesh kushwaha\", \"action\" : \"DELETE\"}\r\nChannel : pg_pigeon_default_channel\r\nPayload : {\"item_no\" : 1, \"item_description\" : \"dinesh kushwaha\", \"action\" : \"DELETE\"}\r\n:: Parent process id , name  : 23512:: Current process id , name  : 19768\r\n:: Waiting for new messages payload ....\r\n```\r\n\r\nNow you can dieselize the payload and you can do anything with it.\r\n\r\n## \u270d\ufe0f Authors <a name = \"authors\"></a>\r\n\r\n- [Dinesh Kushwaha](https://pypi.org/user/dinesh-pypi/) - Idea & Initial work\r\n\r\nSee also the list of [contributors](https://github.com/dinesh-kushwaha) who participated in this project.\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Dinesh Kushwaha  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "This package help to implement realtime db notifications.",
    "version": "1.1.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/pypa/sampleproject/issues",
        "Homepage": "https://github.com/dinesh-kushwaha/pypigeon"
    },
    "split_keywords": [
        "python",
        "postgresql",
        "realtime",
        "notification",
        "pg_notify",
        "channel"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50df94b163d127e0aa85fb83d523f662aa6ffe0cecc6833ab54e124dc401ceb3",
                "md5": "c46a3fa17042f4ec4970683c4a67af35",
                "sha256": "ab37578f6cf6133b7a90d9545088168783590f4e4645907f419ee0033075a7ad"
            },
            "downloads": -1,
            "filename": "pgpigeon-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c46a3fa17042f4ec4970683c4a67af35",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 15521,
            "upload_time": "2023-05-30T13:43:08",
            "upload_time_iso_8601": "2023-05-30T13:43:08.729549Z",
            "url": "https://files.pythonhosted.org/packages/50/df/94b163d127e0aa85fb83d523f662aa6ffe0cecc6833ab54e124dc401ceb3/pgpigeon-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54f910072bf9321f5308e0742f584d19cceeaec13bd73b01ee94da1bbfab99f9",
                "md5": "45d01ed46d62f30f5e33f4719fba7f97",
                "sha256": "492f9c11ebd4bac1c98ef6d04f04e39474965c37bae4b84299ba0203d83892c1"
            },
            "downloads": -1,
            "filename": "pgpigeon-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "45d01ed46d62f30f5e33f4719fba7f97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 13862,
            "upload_time": "2023-05-30T13:43:11",
            "upload_time_iso_8601": "2023-05-30T13:43:11.096775Z",
            "url": "https://files.pythonhosted.org/packages/54/f9/10072bf9321f5308e0742f584d19cceeaec13bd73b01ee94da1bbfab99f9/pgpigeon-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-30 13:43:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pypa",
    "github_project": "sampleproject",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pgpigeon"
}
        
Elapsed time: 0.07578s