# 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.9.0",
"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/78/ea/1281d8b3d5c5dca6ee303cb51c942f26eb17608f0d990c4c20946425af43/taskiq_psqlpy-0.1.7.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.7",
"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": "a81beeccc64dadad1705e3a9c97e5d3381f7ad6f0f9b38f5120f336296217547",
"md5": "2aa5915469739691bbace5501a6b9867",
"sha256": "7e84b677701e25fb810ecdf02acb18f6c581d7ea3e14af16908646d01c49abb0"
},
"downloads": -1,
"filename": "taskiq_psqlpy-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2aa5915469739691bbace5501a6b9867",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.9.0",
"size": 4488,
"upload_time": "2025-08-06T18:34:00",
"upload_time_iso_8601": "2025-08-06T18:34:00.407666Z",
"url": "https://files.pythonhosted.org/packages/a8/1b/eeccc64dadad1705e3a9c97e5d3381f7ad6f0f9b38f5120f336296217547/taskiq_psqlpy-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "78ea1281d8b3d5c5dca6ee303cb51c942f26eb17608f0d990c4c20946425af43",
"md5": "878cf61f5d33edac3cb375ae1d38364e",
"sha256": "fb23ffb0126fa41a48f62d495e7add3933ccafec8a2339ecfd668eb9b24dbc28"
},
"downloads": -1,
"filename": "taskiq_psqlpy-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "878cf61f5d33edac3cb375ae1d38364e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.9.0",
"size": 4425,
"upload_time": "2025-08-06T18:34:01",
"upload_time_iso_8601": "2025-08-06T18:34:01.479904Z",
"url": "https://files.pythonhosted.org/packages/78/ea/1281d8b3d5c5dca6ee303cb51c942f26eb17608f0d990c4c20946425af43/taskiq_psqlpy-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-06 18:34:01",
"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"
}