taskiq-psqlpy


Nametaskiq-psqlpy JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/taskiq-python/taskiq-psqlpy
SummaryPSQLPy and PostgreSQL integration for taskiq
upload_time2024-04-13 23:22:19
maintainerNone
docs_urlNone
authortaskiq-team
requires_python<4.0.0,>=3.8.1
licenseNone
keywords taskiq tasks distributed async postgresql result_backend psqlpy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TaskIQ - PSQLPy

TaskIQ-PSQLPy is a plugin for taskiq that adds a new result backend based on PostgreSQL and [PSQLPy](https://github.com/qaspen-python/psqlpy).

## Installation
To use this project you must have installed core taskiq library:
```bash
pip install taskiq
```

This project can be installed using pip:
```bash
pip install taskiq-psqlpy
```

Or using poetry:
```
poetry add taskiq-psqlpy
```

## Usage
Let's see the example with the redis broker and PostgreSQL PSQLPy result backend:
```python
# broker.py
import asyncio

from taskiq_redis import ListQueueBroker
from taskiq_psqlpy import PSQLPyResultBackend

psqlpy_result_backend = PSQLPyResultBackend(
    dsn="postgres://postgres:postgres@localhost:5432/postgres",
)

# Or you can use PubSubBroker if you need broadcasting
broker = ListQueueBroker(
    url="redis://localhost:6379",
    result_backend=psqlpy_result_backend,
)


@broker.task
async def best_task_ever() -> None:
    """Solve all problems in the world."""
    await asyncio.sleep(5.5)
    print("All problems are solved!")


async def main():
    await broker.startup()
    task = await best_task_ever.kiq()
    print(await task.wait_result())
    await broker.shutdown()


if __name__ == "__main__":
    asyncio.run(main())
```

## PSQLPyResultBackend configuration
- `dsn`: connection string to PostgreSQL.
- `keep_results`: flag to not remove results from Redis after reading.
- `table_name`: name of the table in PostgreSQL to store TaskIQ results.
- `field_for_task_id`: type of a field for `task_id`, you may need it if you want to have length of task_id more than 255 symbols.
- `**connect_kwargs`: additional connection parameters, you can read more about it in [PSQLPy](https://github.com/qaspen-python/psqlpy) repository.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/taskiq-python/taskiq-psqlpy",
    "name": "taskiq-psqlpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.8.1",
    "maintainer_email": null,
    "keywords": "taskiq, tasks, distributed, async, postgresql, result_backend, psqlpy",
    "author": "taskiq-team",
    "author_email": "taskiq@norely.com",
    "download_url": "https://files.pythonhosted.org/packages/69/52/4c0db6873ad3d1594b53d9342170f1a30b27b342c01e5e74b271069a13f5/taskiq_psqlpy-0.1.2.tar.gz",
    "platform": null,
    "description": "# TaskIQ - PSQLPy\n\nTaskIQ-PSQLPy is a plugin for taskiq that adds a new result backend based on PostgreSQL and [PSQLPy](https://github.com/qaspen-python/psqlpy).\n\n## Installation\nTo use this project you must have installed core taskiq library:\n```bash\npip install taskiq\n```\n\nThis project can be installed using pip:\n```bash\npip install taskiq-psqlpy\n```\n\nOr using poetry:\n```\npoetry add taskiq-psqlpy\n```\n\n## Usage\nLet's see the example with the redis broker and PostgreSQL PSQLPy result backend:\n```python\n# broker.py\nimport asyncio\n\nfrom taskiq_redis import ListQueueBroker\nfrom taskiq_psqlpy import PSQLPyResultBackend\n\npsqlpy_result_backend = PSQLPyResultBackend(\n    dsn=\"postgres://postgres:postgres@localhost:5432/postgres\",\n)\n\n# Or you can use PubSubBroker if you need broadcasting\nbroker = ListQueueBroker(\n    url=\"redis://localhost:6379\",\n    result_backend=psqlpy_result_backend,\n)\n\n\n@broker.task\nasync def best_task_ever() -> None:\n    \"\"\"Solve all problems in the world.\"\"\"\n    await asyncio.sleep(5.5)\n    print(\"All problems are solved!\")\n\n\nasync def main():\n    await broker.startup()\n    task = await best_task_ever.kiq()\n    print(await task.wait_result())\n    await broker.shutdown()\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## PSQLPyResultBackend configuration\n- `dsn`: connection string to PostgreSQL.\n- `keep_results`: flag to not remove results from Redis after reading.\n- `table_name`: name of the table in PostgreSQL to store TaskIQ results.\n- `field_for_task_id`: type of a field for `task_id`, you may need it if you want to have length of task_id more than 255 symbols.\n- `**connect_kwargs`: additional connection parameters, you can read more about it in [PSQLPy](https://github.com/qaspen-python/psqlpy) repository.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "PSQLPy and PostgreSQL integration for taskiq",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/taskiq-python/taskiq-psqlpy",
        "Repository": "https://github.com/taskiq-python/taskiq-psqlpy"
    },
    "split_keywords": [
        "taskiq",
        " tasks",
        " distributed",
        " async",
        " postgresql",
        " result_backend",
        " psqlpy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a19f20967b99422dfab321e8770c3593ed39a0d0112a2c83701da6c31fa16aef",
                "md5": "ebfec88d5fe02f8b3ca4e90d180b2561",
                "sha256": "79a9f9e4bb27fc4bdc4d61c4f0c48a936d261944f491d5fbcffaef1e6fc464f1"
            },
            "downloads": -1,
            "filename": "taskiq_psqlpy-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ebfec88d5fe02f8b3ca4e90d180b2561",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 4307,
            "upload_time": "2024-04-13T23:22:17",
            "upload_time_iso_8601": "2024-04-13T23:22:17.737988Z",
            "url": "https://files.pythonhosted.org/packages/a1/9f/20967b99422dfab321e8770c3593ed39a0d0112a2c83701da6c31fa16aef/taskiq_psqlpy-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69524c0db6873ad3d1594b53d9342170f1a30b27b342c01e5e74b271069a13f5",
                "md5": "58f6518347db56d795f60611c9f5993e",
                "sha256": "e2c8f8cbb9bdaddbd22cfd1f30b942f930f6b44c8509a04d6405e2c7fc0456ee"
            },
            "downloads": -1,
            "filename": "taskiq_psqlpy-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "58f6518347db56d795f60611c9f5993e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 4406,
            "upload_time": "2024-04-13T23:22:19",
            "upload_time_iso_8601": "2024-04-13T23:22:19.229464Z",
            "url": "https://files.pythonhosted.org/packages/69/52/4c0db6873ad3d1594b53d9342170f1a30b27b342c01e5e74b271069a13f5/taskiq_psqlpy-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-13 23:22:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "taskiq-python",
    "github_project": "taskiq-psqlpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "taskiq-psqlpy"
}
        
Elapsed time: 0.29919s