Skip to main content

SQLAlchemy integration for taskiq

Project description

TaskIQ - SQLAlchemy

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

The broker uses polling to fetch messages.

Usage

import asyncio

from taskiq_sqlalchemy import SQLAlchemyBroker, SQLAlchemyResultBackend

# can be a sqlalchemy connection string or a instance of sqlalchemy Engine or AsyncEngine
connection_string = "sqlite:///tasks.db"


result_backend = SQLAlchemyResultBackend(connection_string)

broker = SQLAlchemyBroker(connection_string).with_result_backend(result_backend)

@broker.task()
async def my_add_task(a:int|float, b:int|float) -> int|float:
    await asyncio.sleep(1)
    return a + b

async def main():
    await broker.startup()
    task = await my_add_task.kiq(1, 1)
    result = await task.wait_result()
    print(result)


if __name__ == "__main__":
    asyncio.run(main())

Tests

This library has been tested against the following database and drivers:

  • SQLite: sqlite(sync), aiosqlite(async)
  • Postgres: psycopg(sync), psycopg(async)
  • Mysql: pymysql(sync)
  • SQLServer: pymssql(sync)

Considerations

Although both sync and async engines are supported, you should prefer to use async engines where possible as the sync methods block while reading the database.

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_sqlalchemy-0.1.1.tar.gz (4.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_sqlalchemy-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file taskiq_sqlalchemy-0.1.1.tar.gz.

File metadata

  • Download URL: taskiq_sqlalchemy-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for taskiq_sqlalchemy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9ce6d068b6d3214e6ff054fea0f48aa5f4374600d4b381301cccd8039ff83bdd
MD5 cb4ce9f9c3f4bc6da339c96ed87c874d
BLAKE2b-256 15fe808d1519e52083b116ad7af4f362f00c95c46897ef88bb47ceaa4788e5d2

See more details on using hashes here.

File details

Details for the file taskiq_sqlalchemy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: taskiq_sqlalchemy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for taskiq_sqlalchemy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f928bbeb71b4a634132e8ffa4267ac039fdfea25cfcf762e14c0acebda36336
MD5 49c5390a6d01c84159e8b6a9a83cb086
BLAKE2b-256 1ffbac30e31ba993dfb4c7f7edb8da50f3bb869cda4a82a57e49594e9316c0e8

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