Metadata-Version: 2.4
Name: mqtt_processor
Version: 0.1.0
Summary: A Python package for real-time MQTT data processing with database integration
Home-page: https://github.com/Deep26011999/mqtt-data-processor
Author: Deep Shikhar Singh
Author-email: deepshikharsingh@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: paho-mqtt==2.1.0
Requires-Dist: psycopg2==2.9.10
Requires-Dist: python-dotenv==1.1.0
Requires-Dist: dnspython==2.7.0
Requires-Dist: pytest==7.0.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 📦 mqtt-processor

[![PyPI version](https://badge.fury.io/py/mqtt-processor-deep.svg)](https://badge.fury.io/py/mqtt-processor-deep)
[![Build Status](https://github.com/yourusername/mqtt-data-processor/actions/workflows/python-package.yml/badge.svg)](https://github.com/yourusername/mqtt-data-processor/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A lightweight and extensible Python package for processing MQTT messages and storing them in PostgreSQL. Ideal for IoT data pipelines, sensor networks, and real-time applications.

---

## ✨ Features

- 🔗 MQTT broker integration
- 🛠️ Plug-and-play message transformations
- 🗃️ PostgreSQL message storage
- ✅ Clean, testable architecture
- 🧪 Built-in pytest compatibility
- 🐳 Docker-friendly

---

## 🧰 Prerequisites – Mosquitto MQTT Broker Setup
✅ Install Mosquitto (Windows)
Download from: https://mosquitto.org/download/

Install with default options (add to PATH recommended).

Verify installation:

mosquitto -v
🚀 Run Mosquitto Broker
Start broker manually (if not running as service):
```
mosquitto -v
```
Keep this terminal open.

📤 Publish Message (PowerShell Admin)
```
& "C:\Program Files\mosquitto\mosquitto_pub.exe" -h localhost -t sensor/temp -m '{\"temperature\": 44}'
```
📥 Subscribe to Topic (PowerShell Admin)
```
mosquitto_sub -h localhost -t sensor/temp
```
---

## 📦 Installation

From PyPI:

```bash
pip install mqtt-processor

git clone https://github.com/Deep26011999/mqtt-data-processor.git
cd mqtt-data-processor
pip install .

🚀 Basic Usage

from mqtt_processor.client import MQTTClient

client = MQTTClient()
client.start()

# Your app logic here

client.stop()


🔄 Custom Message Transformation

def uppercase_payload(topic, payload):
    return topic, payload.upper()

client = MQTTClient(process_function=uppercase_payload)
client.start()


⚙️ Configuration
You can configure MQTT and PostgreSQL either via environment variables or by editing the default config.py.


# MQTT
export MQTT_BROKER="localhost"
export MQTT_PORT=1883
export MQTT_TOPIC="sensor/#"

# PostgreSQL
export DB_HOST="localhost"
export DB_PORT=5432
export DB_NAME="mqtt_db"
export DB_USER="your_user"
export DB_PASSWORD="your_password"


🧪 Running Tests
Install development requirements:


pip install -r requirements-dev.txt
Run all tests:


pytest tests/
To test a specific file:


pytest tests/test_client.py


📁 Project Structure
arduino
Copy
Edit
mqtt-data-processor/
├── src/
│   └── mqtt_processor/
│       ├── __init__.py
│       ├── client.py
│       ├── config.py
│       ├── db_connector.py
│       ├── processor.py
│       └── utils.py
├── tests/
│   └── test_client.py
├── .gitignore
├── requirements.txt
├── setup.py
└── README.md

🔐 Security
Always store sensitive credentials like database passwords in environment variables or secure vaults — avoid hardcoding them in config.py.

📜 License
MIT © [Deep Shikhar Singh]
See LICENSE for details.

🙌 Contributing
Contributions are welcome! Feel free to open issues or pull requests.
If you find this project helpful, give it a ⭐ on GitHub!


🌍 Links
📦 PyPI: mqtt-processor

🛠️ GitHub Repo
