Metadata-Version: 2.1
Name: pgqmini
Version: 0.0.3
Summary: pgqmini is a lightweight, easy-to-use Python library for managing PostgreSQL message queues.
Home-page: http://github.com/over-engineers/pgqmini
Author: Kajago
Author-email: jangsc0000@gmail.com
License: MIT
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: psycopg2-binary

# **pgqmini**

![version](https://img.shields.io/badge/version-0.0.3-blue)
![license](https://img.shields.io/badge/license-MIT-green)

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](#installation)**
2. **[Usage](#usage)**
3. **[Contributing](#contributing)**
4. **[License](#license)**
5. **[Contact](#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**
```python
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_message('{"key1": "value1", "key2": "value2"}')

pgq.disconnect()
```

### **Subscriber**
```python
from pgqmini import PGQ

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

pgq.connect()

while True:
    try:
        msg = pgq.sub_message()
        process_message(msg)
        pgq.complete_message(msg)
    except Exception as e:
        pgq.rollback_message(msg)
```

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](https://github.com/over-engineers/pgqmini/wiki/PGQ-Class-Documentation) 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**.
