# TTN MQTT to PostgreSQL Python service

**URL:** <https://www.thethingsnetwork.org/forum/t/ttn-mqtt-to-postgresql-python-service/53860>\
**Category:** Use Cases\
**Created:** [December 13, 2021, 5:23pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-mqtt-to-postgresql-python-service/53860 "2021-12-13T17:23:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gms](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/gms/32/35697_2.png) [@gms](https://www.thethingsnetwork.org/forum/u/gms)\
**Post date:** [December 13, 2021, 5:23pm UTC](https://www.thethingsnetwork.org/forum/t/ttn-mqtt-to-postgresql-python-service/53860/1 "2021-12-13T17:23:50Z")

</div>

In order to get some sensor data into a Postgres database for consumption by Grafana dashboards and other applications I wrote a small Python service: `ttnmqtt2pg`

It’s available in a git repository ([GitHub - gsauthof/lorawan: Stream LoRaWAN messages to PostgreSQL](https://github.com/gsauthof/lorawan)) which also includes a README that details the schema and some design decisions.

That repository also contains some Ansible roles for setting everything up.

Some example Grafana panel based on the streamed data:

![Screenshot from 2021-12-13 18-16-46](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/1/f/1f45be75a78289d6d6bf46bbb3723cb81af32af6.png)

The RSSI of those device for the same time period:

![Screenshot from 2021-12-13 18-19-53](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/1/a/1aa96b988b7d7b4baf0053a92ecf55482916d875.png)

SNR:

![Screenshot from 2021-12-13 18-21-19](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/4/0/40e63304ff9d89f13dbcecf616eabb38d674d0d1.png)
