Skip to content

jangsc0000/pgqmini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgqmini

version license

pgqmini is a lightweight, easy-to-use Python library for managing PostgreSQL message queues. It provides a simple interface for adding and retrieving messages from a PostgreSQL-based queue, as well as handling timeouts and managing message processing.

Table of Contents

  1. Installation
  2. Usage
  3. Contributing
  4. License
  5. Contact

Installation

To install pgqmini, you can use pip:

pip install pgqmini

You also need to have a PostgreSQL server up and running. The library uses the psycopg2 package to connect to the PostgreSQL server.

Usage

Here is a basic example of how to use pgqmini:

Publisher

from pgqmini import PGQ

pgq = PGQ(
    qname="message_queue",
    dbname="pgq",
    host="127.0.0.1",
    user="username",
    password="password",
    port=5432,
)

pgq.connect()

pgq.pub('{"key1": "value1", "key2": "value2"}')

pgq.disconnect()

Subscriber

from pgqmini import PGQ

pgq = PGQ(
    qname="message_queue",
    dbname="pgq",
    host="127.0.0.1",
    user="username",
    password="password",
    port=5432,
)

pgq.connect()

def process_message(payload: str):
    print(payload)

while True:
    pgq.sub(process_message)

In this code, we first create a PGQ object with the necessary database connection parameters. We then connect to the database and enter a loop where we process messages from the queue.

For a more detailed usage guide, please check out the Usage Guide in our wiki.

License

pgqmini is released under the MIT License. See the LICENSE file for more details.

Contact

If you have any questions, issues, or suggestions, please open an issue in this repository, or contact the maintainer at jangsc0000@gmail.com.

About

pgqmini is a lightweight, easy-to-use Python library for managing PostgreSQL message queues.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages