database websocket

documentation
This commit is contained in:
Bram Barbieri
2024-03-14 18:46:46 +01:00
parent 6c60a184b8
commit a2ff97d7fb

View File

@@ -1,13 +1,19 @@
## Python code + explaination ## Python code + explaination
We wanted to make a working connection between our websocket wich runs all the data gatherd by our nodes and a live feed to our database.
So we set out to make this connection using python.
At first we needed to import the folowing librarys:
```js ```js
// Here different librarys are imported to
// everything is running async so the code can run together and not interfere with eachother. // everything is running async so the code can run together and not interfere with eachother.
import asyncio import asyncio
import websockets import websockets
// a library to connect to the database. // a library to connect to the database.
import mysql.connector import mysql.connector
import json import json
```
Then we began the process of connecting with both the websocket and the database.
```js
//the data that has to be pushed needs to be //the data that has to be pushed needs to be
async def process_data(data): async def process_data(data):
try: try: