PostgreSQL integration for taskiq
Project description
PostgreSQL integration for Taskiq with support for asyncpg, psqlpy and aiopg drivers.
Installation
Depend on your preferred PostgreSQL driver, you can install this library:
# with asyncpg
pip install taskiq-postgres[asyncpg]
# with psqlpy
pip install taskiq-postgres[psqlpy]
# with aiopg
pip install taskiq-postgres[aiopg]
Usage
Simple example of usage with asyncpg:
# broker.py
import asyncio
from taskiq_pg.asyncpg import AsyncpgResultBackend, AsyncpgBroker
result_backend = AsyncpgResultBackend(
dsn="postgres://postgres:postgres@localhost:5432/postgres",
)
broker = AsyncpgBroker(
dsn="postgres://postgres:postgres@localhost:5432/postgres",
).with_result_backend(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())
Your experience with other drivers will be pretty similar. Just change the import statement and that's it.
Motivation
There are too many libraries for PostgreSQL and Taskiq integration. Although they have different view on interface and different functionality. To address this issue I created this library with a common interface for most popular PostgreSQL drivers that handle similarity across functionality of result backends and brokers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file taskiq_postgres-0.1.1.tar.gz.
File metadata
- Download URL: taskiq_postgres-0.1.1.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
616acf6b72aefa8b2a6a40d3fd1823fda0d1b09b2dfbb09facb162b8d1e0b881
|
|
| MD5 |
8e97766ec174cda73af7e7f00f5aa2f8
|
|
| BLAKE2b-256 |
c232ed4eb99f271221bc2aa068d5ed32a82b81a9aba47e4eb1f5e5dcb4abec5f
|
File details
Details for the file taskiq_postgres-0.1.1-py3-none-any.whl.
File metadata
- Download URL: taskiq_postgres-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0acd70ec29c5fb8aea39974e81404ee77b875fa7bc77fac9a36d377e566eed79
|
|
| MD5 |
3fe0a0306af3378f2d28423f4c96388c
|
|
| BLAKE2b-256 |
b0bcf086bea9205ca9f38092c000a446ffeb1a01fd1d702f671928edbea96187
|