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.0.tar.gz (12.0 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.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for taskiq_postgres-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1064ac9db83189ad8afabed6efd989a16f9d034b718d432d0ee822b4735e51c9
MD5 87686495969d1c7cceda2a997bf375df
BLAKE2b-256 e2cd94c36bf8adc338d7bf5868218687a2a48d64e7518490dc280d9f0869fb1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for taskiq_postgres-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac89be6737091b0bbc0035f8ee9f3003146eb729cde8d0ee715b3608f7a3ccfb
MD5 bb4062f1ee68c8854483195b60182be3
BLAKE2b-256 f675de70408c40a74b3015123dd8ec3072b6bb2b6228acf961c48001cded5f06

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