{"id":19310520,"url":"https://github.com/sepppenner/mqtt2mysqlbridge","last_synced_at":"2025-04-22T13:34:25.176Z","repository":{"id":82869176,"uuid":"146170495","full_name":"SeppPenner/MQTT2MySQLBridge","owner":"SeppPenner","description":"MQTT2MySQLBridge is a project to connect a locally running broker to a MySQL database and store the messages in a database table. The project was written and tested in Python 3.","archived":false,"fork":false,"pushed_at":"2024-05-22T15:40:54.000Z","size":24,"stargazers_count":7,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-22T16:52:09.788Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SeppPenner.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-26T10:16:27.000Z","updated_at":"2023-08-31T16:51:35.000Z","dependencies_parsed_at":"2023-07-09T18:00:11.745Z","dependency_job_id":null,"html_url":"https://github.com/SeppPenner/MQTT2MySQLBridge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2MySQLBridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2MySQLBridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2MySQLBridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2MySQLBridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeppPenner","download_url":"https://codeload.github.com/SeppPenner/MQTT2MySQLBridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223899223,"owners_count":17221900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T00:24:37.322Z","updated_at":"2024-11-10T00:24:38.384Z","avatar_url":"https://github.com/SeppPenner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQTT2MySQLBridge\n\nMQTT2MySQLBridge is a project to connect a locally running broker to a MySQL database and store the messages in a database table. The project was written and tested in Python 3.\n\n[![Build status](https://ci.appveyor.com/api/projects/status/69v4b50ts5639ev4?svg=true)](https://ci.appveyor.com/project/SeppPenner/mqtt2mysqlbridge)\n[![GitHub issues](https://img.shields.io/github/issues/SeppPenner/MQTT2MySQLBridge.svg)](https://github.com/SeppPenner/MQTT2MySQLBridge/issues)\n[![GitHub forks](https://img.shields.io/github/forks/SeppPenner/MQTT2MySQLBridge.svg)](https://github.com/SeppPenner/MQTT2MySQLBridge/network)\n[![GitHub stars](https://img.shields.io/github/stars/SeppPenner/MQTT2MySQLBridge.svg)](https://github.com/SeppPenner/MQTT2MySQLBridge/stargazers)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://raw.githubusercontent.com/SeppPenner/MQTT2MySQLBridge/master/License.txt)\n[![Known Vulnerabilities](https://snyk.io/test/github/SeppPenner/MQTT2MySQLBridge/badge.svg)](https://snyk.io/test/github/SeppPenner/MQTT2MySQLBridge) \n\n## Adjust your settings:\n\n* Adjust the broker to the address you want to use: `broker_source`\n* Add your custom filters to `filterMessage()` if you want to filter messages\n* Adjust your credentials (uncomment if anonymous): \n\n```python\nclient_source.username_pw_set(\"mqtt\", \"IoT\")\n```\n\n* Adjust your MySQL credentials:\n\n```python\nDatabaseHostName = 'YourHost'\nDatabaseUserName = 'YourUser'\nDatabasePassword = 'YourPassword'\nDatabasePort = 3306\n```\n\n* Run the script `SetupDatabase.sql` on your database to setup the database correctly\n\n* Add filters to the bridging like described in the `bridgeFiltering.py` file if needed:\n\n```python\ndef filterMessage(payload, topic, qos):\n\t\"Filters the messages depending on the configuration for the attributes payload, topic and QoS. 'True' means that the message is not forwarded.\"\n\t# Examples below:\n\tif(payload == \"10 %\"):\n\t\tprint('Filtered: payload == \"10 %\"')\n\t\treturn True\n\tif(topic == \"humidity\" and qos == 0):\n\t\tprint('Filtered: topic == \"humidity\" and qos == 0')\n\t\treturn True\n\tif(topic == \"temperature\" or qos == 2):\n\t\tprint('Filtered: topic == \"temperature\" or qos == 2')\n\t\treturn True\n\t#Add your filters here\n```\n\n## Setup on the Raspberry Pi\n\n```bash\nsudo apt-get install python3\nsudo apt-get install python3-pip\nsudo pip3 install paho-mqtt\nsudo pip3 install pymysql\n```\n\nor\n\n```bash\nsudo apt-get install python3\nsudo apt-get install python3-pip\nsudo pip3 install -r requirements.txt\n```\n\n## Running the programms:\n\n```bash\npython3 bridge.py\npython3 bridgeFiltering.py\n```\n\n## Installing the latest version of Python (Currently 3.7.4) on the Raspberry Pi:\n\nhttps://gist.github.com/SeppPenner/6a5a30ebc8f79936fa136c524417761d\n\n## Paho MQTT client documentation\n\n* https://pypi.org/project/paho-mqtt/\n* https://www.hivemq.com/blog/mqtt-client-library-paho-python\n\n## See also\n\n* [MQTT2AWSS3Bridge](https://github.com/SeppPenner/MQTT2AWSS3Bridge)\n* [MQTT2PostgresBridge](https://github.com/SeppPenner/MQTT2PostgresBridge)\n* [MQTT2MQTTBridge](https://github.com/SeppPenner/MQTT2MQTTBridge)\n\nChange history\n--------------\n\nSee the [Changelog](https://github.com/SeppPenner/MQTT2MySQLBridge/blob/master/Changelog.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsepppenner%2Fmqtt2mysqlbridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsepppenner%2Fmqtt2mysqlbridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsepppenner%2Fmqtt2mysqlbridge/lists"}