Skip to main content

PostgreSQL integration for taskiq

Project description

PyPI - Python Version PyPI Checks


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taskiq_postgres-0.1.2.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskiq_postgres-0.1.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file taskiq_postgres-0.1.2.tar.gz.

File metadata

  • Download URL: taskiq_postgres-0.1.2.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.3

File hashes

Hashes for taskiq_postgres-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e437d6f856d56c12ccd93e39c63c7d41d0fb4858cee68103f6d9b88b5b3f35b4
MD5 5dbef722686d40ff18d84d38352759fa
BLAKE2b-256 d1fab7753755080047b42f97ed99ab781a48acdebdf3d94d0663e2f05c179a64

See more details on using hashes here.

File details

Details for the file taskiq_postgres-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for taskiq_postgres-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8c49791162c32d3a1f263df5155e364334a7eba006fba3074e0e3bff45f6add9
MD5 2e270e22f890e17f80147792033c9816
BLAKE2b-256 dcd7a22709573f72accaba9b6063d127defa19b66198f96b7bd157dc0a993a00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page