database websocket
documentation
This commit is contained in:
@@ -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:
|
||||||
|
Reference in New Issue
Block a user