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.

See more example of usage in the documentation.

Installation

Depend on your preferred PostgreSQL driver, you can install this library:

=== "asyncpg"

```bash
pip install taskiq-postgres[asyncpg]
```

=== "psqlpy"

```bash
pip install taskiq-postgres[psqlpy]
```

=== "aiopg"

```bash
pip install taskiq-postgres[aiopg]
```

Usage example

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, brokers and schedule sources.

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.2.0.tar.gz (8.8 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.2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for taskiq_postgres-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c7e5ff37e251c2b6e429e29624e02ebbf6a1ad21e68f8b0b4fe0eed84c552de1
MD5 4b7f604fd60b0ba20c40ff0fbd656088
BLAKE2b-256 594d1dd307ef02d24d868d743c06664366ce585b27c55426a8b8f6675cb03bf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for taskiq_postgres-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1af455b7af5de8f09b274f5d356d65e354ec873d5019200cd355891397f78e81
MD5 f8fcfe3c0e6e132f7766e012a3e242cd
BLAKE2b-256 cc94f97334258b5ac3d35eed00374db84f9e6c3c4d0dd295f32e1b6458bb1260

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