pgque
A simple message queue based on PostgreSQL's FOR UPDATE SKIP LOCKED.
Installation
Install the basic synchronous version:
pip install pgque
To use the asynchronous version, you need to install the async extra, which includes the asyncpg driver:
pip install pgque[async]
If you prefer to use psycopg2 instead of psycopg (v3) for the synchronous version, you can install the psycopg2 extra:
pip install pgque[psycopg2]
Usage
First, you need to create the message table in your database. You can optionally specify a custom table name.
from pgque import create_tables
database_url = "postgresql://user:password@host:port/dbname"
# Create a table with the default name "messages"
create_tables(database_url)
# Or, create a table with a custom name
create_tables(database_url, table_name="my_messages")
Synchronous
from pgque import get_sync_queue
# Connect to a queue with the default table name
queue = get_sync_queue("postgresql+psycopg://user:password@host:port/dbname")
# Connect to a queue with a custom table name
custom_queue = get_sync_queue(
"postgresql+psycopg://user:password@host:port/dbname",
table_name="my_messages",
)
# Send a message
custom_queue.send_message("my_queue", {"hello": "world"})
# Receive a message
message = custom_queue.receive_message("my_queue")
if message:
print(message["payload"])
custom_queue.complete_message(message["id"])
Asynchronous
import asyncio
from pgque import get_async_queue
async def main():
# Connect to a queue with a custom table name
queue = get_async_queue(
"postgresql+asyncpg://user:password@host:port/dbname",
table_name="my_messages",
)
# Send a message
await queue.send_message("my_queue", {"hello": "world"})
# Receive a message
message = await queue.receive_message("my_queue")
if message:
print(message["payload"])
await queue.complete_message(message["id"])
await queue.close()
asyncio.run(main())
Metadata
Release files for pgque 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 |
|---|---|---|---|---|
| pgque-0.1.0.tar.gz | 42.1 kB | Without provenance | Details for pgque-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pgque-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pgque-0.1.0-py3-none-any.whl |
Total release size: 50.0 kB
Release files / pgque-0.1.0.tar.gz
| Download URL | pgque-0.1.0.tar.gz |
|---|---|
| Size | 42.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c714f46622ddf1c609972eb14afc4e38a52d1567860c89db9e25b60a1715c11
|
|
BLAKE2b-256 checksum How to use checksums |
c32d8c6f2a138af8f67c79d27e77bba829749db45710523edb5c88d858216445
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Release files / pgque-0.1.0-py3-none-any.whl
| Download URL | pgque-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4dc4ca52a393cf5c404aedec4d7127f536c99720baeffbca69b6e25ca03c4ed8
|
|
BLAKE2b-256 checksum How to use checksums |
18354b0d8e6b3ab64a93fd07326685828639289cce56fe2704b9dd5d6a0f6c4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Security for pgque 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.