taskiq-psqlpy


Nametaskiq-psqlpy JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/taskiq-python/taskiq-psqlpy
SummaryPSQLPy and PostgreSQL integration for taskiq
upload_time2024-10-18 10:54:35
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/c7/93/753b9a7176a0c6523cde11e83860d4e54e321dc83a69baed7d0dbd9add29/taskiq_psqlpy-0.1.4.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.4",
    "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": "7d730d1c9067b9a78642969495455115cde81631dbc164be9f68128538503264",
                "md5": "0a23f85b1cff53cc958c7678ce8300ab",
                "sha256": "e38dd720a9d361daec0ae214f9e3294c555db4e0dcf559cfb58181ad3f5ee364"
            },
            "downloads": -1,
            "filename": "taskiq_psqlpy-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0a23f85b1cff53cc958c7678ce8300ab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 4295,
            "upload_time": "2024-10-18T10:54:34",
            "upload_time_iso_8601": "2024-10-18T10:54:34.409849Z",
            "url": "https://files.pythonhosted.org/packages/7d/73/0d1c9067b9a78642969495455115cde81631dbc164be9f68128538503264/taskiq_psqlpy-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c793753b9a7176a0c6523cde11e83860d4e54e321dc83a69baed7d0dbd9add29",
                "md5": "0978303002131798dcdc49b61eef1cbf",
                "sha256": "4bae27c096cec7f174f16752ff371b24dfa1ce0a14c7e70033af11e9347a1a30"
            },
            "downloads": -1,
            "filename": "taskiq_psqlpy-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "0978303002131798dcdc49b61eef1cbf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 4398,
            "upload_time": "2024-10-18T10:54:35",
            "upload_time_iso_8601": "2024-10-18T10:54:35.794517Z",
            "url": "https://files.pythonhosted.org/packages/c7/93/753b9a7176a0c6523cde11e83860d4e54e321dc83a69baed7d0dbd9add29/taskiq_psqlpy-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-18 10:54:35",
    "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.76494s