Python client for the PGMQ Postgres extension.
Project description
Coredb's Python Client for PGMQ
Installation
Install with pip
from pypi.org
pip install coredb-pgmq-python
Dependencies
Postgres running the CoreDB PGMQ extension.
Usage
Start a Postgres Instance with the CoreDB extension installed
docker run -d -p 5432:5432 quay.io/coredb/coredb-pg:latest
Initialize a connection to Postgres
from coredb_pgmq_python import PGMQueue, Message
queue = PGMQueue(host="0.0.0.0")
Create a queue (or a partitioned queue)
queue.create_queue("my_queue")
# queue.create_partitioned_queue("my_partitioned_queue", partition_size=10000)
Send a message
msg_id: int = queue.send("my_queue", {"hello": "world"})
Read a message, set it invisible for 30 seconds.
read_message: Message = queue.read("my_queue", vt=10)
print(read_message)
Archive the message after we're done with it. Archived messages are moved to an archive table.
archived: bool = queue.archive("my_queue", read_message.msg_id)
Delete a message completely.
msg_id: int = queue.send("my_queue", {"hello": "world"})
read_message: Message = queue.read("my_queue")
deleted: bool = queue.delete("my_queue", read_message.msg_id)
Pop a message, deleting it and reading it in one transaction.
popped_message: Message = queue.pop("my_queue")
print(popped_message)
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
Built Distribution
Close
Hashes for coredb_pgmq_python-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f89472f7c790c8682a5ec72fde3ecbb1b2b1b0996e34e91ccbcdd30d809abf |
|
MD5 | 270f6bca134c6d39bcf1c7401a48f6dc |
|
BLAKE2b-256 | 2933607ebaa4db3cfd8648d6ea992f4503310b90cfdb52b1fdd67f1a8c2d6b38 |