Storing device events into PostgreSQL database

Hello Thomas,

Sure I can help you with that.

I created a new database just for my lora data storage but I used the same loraserver_as user:

sudo -u postgres psql

Create the lorastore database with owner loraserver_as:

create database lorastore with owner loraserver_as;

I then inserted all of the suggested tables and indices outlined by .@brocaar in a file. Here are his suggestions just for reference:
https://github.com/brocaar/lora-app-server/blob/master/docs/content/integrate/sending-receiving/postgresql.md

To save you some time, I’ve recreated that here in a database dump for you:

https://pastebin.com/raw/LzsGb8b9

Download that file then just import it into the database:
psql lorastore < LzsGb8b9

Now you just need to enable the integration:

[application_server.integration]
enabled=[“mqtt”, “postgresql”]

Add the dsn:

[application_server.integration.postgresql]
dsn=“postgres://loraserver_as:YourPasswordHere@localhost/lorastore?sslmode=disable”

Restart the lora-app-server and you’re ready to go. You should see the integration connecting or failing to connect in the logs.

7 Likes