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 --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 quay.io/coredb/pgmq-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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coredb_pgmq_python-0.2.2.tar.gz.
File metadata
- Download URL: coredb_pgmq_python-0.2.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1037-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b6695a50182471bd1934938ee02a0c13b302427bb1860429ab89d14f5804fa8
|
|
| MD5 |
f8d1cf91b56ce7417d3a9830cc0f0cf2
|
|
| BLAKE2b-256 |
461a27cb3f488d88d4a7be2ef0648e26ec2666e6e85e69db53cb44513d1403be
|
File details
Details for the file coredb_pgmq_python-0.2.2-py3-none-any.whl.
File metadata
- Download URL: coredb_pgmq_python-0.2.2-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1037-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ca4cee95cbccb6d6f418b69b03bb83946e6740915989ef2c24f02634a9af2f9
|
|
| MD5 |
d7605dc2d4c1d71fae104c897b0081d9
|
|
| BLAKE2b-256 |
fecc0a4e98c7bd37313d4a4067742e686457bfb14822b8613afd5a2ba0d7c606
|