Skip to main content

PSQLPy and PostgreSQL integration for taskiq

Project description

TaskIQ - PSQLPy

TaskIQ-PSQLPy is a plugin for taskiq that adds a new result backend based on PostgreSQL and PSQLPy.

Installation

To use this project you must have installed core taskiq library:

pip install taskiq

This project can be installed using pip:

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:

# 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 repository.

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_psqlpy-0.1.4.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

taskiq_psqlpy-0.1.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file taskiq_psqlpy-0.1.4.tar.gz.

File metadata

  • Download URL: taskiq_psqlpy-0.1.4.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.9.20 Linux/6.5.0-1025-azure

File hashes

Hashes for taskiq_psqlpy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4bae27c096cec7f174f16752ff371b24dfa1ce0a14c7e70033af11e9347a1a30
MD5 0978303002131798dcdc49b61eef1cbf
BLAKE2b-256 c793753b9a7176a0c6523cde11e83860d4e54e321dc83a69baed7d0dbd9add29

See more details on using hashes here.

File details

Details for the file taskiq_psqlpy-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: taskiq_psqlpy-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.9.20 Linux/6.5.0-1025-azure

File hashes

Hashes for taskiq_psqlpy-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e38dd720a9d361daec0ae214f9e3294c555db4e0dcf559cfb58181ad3f5ee364
MD5 0a23f85b1cff53cc958c7678ce8300ab
BLAKE2b-256 7d730d1c9067b9a78642969495455115cde81631dbc164be9f68128538503264

See more details on using hashes here.

Supported by

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