DBJobQ
Database-backed Job Queue for Python. Supports multiple storage backends: SQLAlchemy, MongoDB, Redis, DynamoDB.
Installation
# Basic installation (includes scheduling support)
pip install dbjobq
# Or install with specific storage backend(s)
pip install dbjobq[sqlalchemy] # SQLAlchemy with async drivers
pip install dbjobq[mongo] # MongoDB
pip install dbjobq[redis] # Redis
pip install dbjobq[dynamo] # DynamoDB
# Or install all storage backends
pip install dbjobq[all]
Development Installation
# Install uv if not already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the project
git clone <repo-url>
cd dbjobq
# Sync dependencies with all extras and dev tools
uv sync --all-extras
Usage
Define Jobs
from dbjobq import job
@job
def my_background_task(data):
print(f"Processing {data}")
# Do work
Create Job Queue
from dbjobq import JobQueue, Worker
from dbjobq.storage import SQLAlchemyStorage
# For SQLAlchemy
storage = SQLAlchemyStorage('sqlite:///jobs.db')
job_queue = JobQueue(storage)
# Enqueue a job
job_id = job_queue.enqueue(my_background_task, {'key': 'value'})
# Inspect the queue
pending_jobs = job_queue.get_pending_jobs()
running_jobs = job_queue.get_running_jobs()
completed_jobs = job_queue.get_completed_jobs()
failed_jobs = job_queue.get_failed_jobs()
# Get a specific job
job = job_queue.get_job(job_id)
if job:
print(f"Job {job.id}: {job.type} - {job.status}")
# List all jobs or filter by status
all_jobs = job_queue.list_jobs()
pending_only = job_queue.list_jobs(status="pending", limit=10)
# Start a worker
worker = Worker(job_queue)
worker.start()
# Later, stop the worker
worker.stop()
Storage Backends
- SQLAlchemy: Supports any SQL database.
- MongoDB:
MongoStorage(mongo_url, db_name) - Redis:
RedisStorage(redis_url) - DynamoDB:
DynamoStorage(table_name, region_name)
Features
- Cross-process job locking
- Multiple storage backends
- Simple API similar to Celery
- Suitable for web apps like FastAPI with Gunicorn
Development
# Run tests
uv run pytest
# Run the example
uv run python hello.py
Metadata
Release files for dbjobq 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dbjobq-0.1.0.tar.gz | 197.1 kB | Without provenance | Details for dbjobq-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dbjobq-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dbjobq-0.1.0-py3-none-any.whl |
Total release size: 219.8 kB
Release files / dbjobq-0.1.0.tar.gz
| Download URL | dbjobq-0.1.0.tar.gz |
|---|---|
| Size | 197.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4133187ba4b50b0e3413acdacb1b317996834b05e7a6012c57a1b801419ae9aa
|
|
BLAKE2b-256 checksum How to use checksums |
f9da189751c0573f8cc5c823770e1eb3f8de75f5b370fb253ca4205f25ed1491
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / dbjobq-0.1.0-py3-none-any.whl
| Download URL | dbjobq-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d85ff223fb7302500ed45dd6f613f4ef4c72c168104d1b803a6cfbcf15f832e5
|
|
BLAKE2b-256 checksum How to use checksums |
4b1e6f874d74b23cbe8dc817a72560867f180c429e30ca684615232527dbc7aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for dbjobq 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.