2026-03-02 21:46:51 +01:00
|
|
|
import asyncio, os
|
|
|
|
|
from typing import Annotated, Final
|
2026-03-17 19:38:27 +01:00
|
|
|
from db.Influx import fluxDataWriter
|
|
|
|
|
from db.MariaDB import sqlDataWriter
|
2026-03-02 21:46:51 +01:00
|
|
|
|
|
|
|
|
USEINFLUX: Final[int] = int(os.getenv("USEINFLUX", 1))
|
|
|
|
|
USESQL: Final[int] = int(os.getenv("USESQL", 0))
|
|
|
|
|
|
|
|
|
|
async def ALLdbIDRACWriter(inputQueue: asyncio.Queue) -> None:
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
|
|
# print(inputQueue)
|
|
|
|
|
|
|
|
|
|
qu = await inputQueue.get()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if USESQL:
|
2026-03-17 19:38:27 +01:00
|
|
|
sqlResult = await sqlDataWriter(qu)
|
2026-03-02 21:46:51 +01:00
|
|
|
match sqlResult:
|
|
|
|
|
case 1:
|
|
|
|
|
print("Wrong source")
|
|
|
|
|
case 2:
|
|
|
|
|
print("Error inserting to database")
|
|
|
|
|
case 3:
|
|
|
|
|
print("No engine defined")
|
|
|
|
|
case _:
|
|
|
|
|
print("Inserted in SQL")
|
|
|
|
|
if USEINFLUX:
|
2026-03-17 19:38:27 +01:00
|
|
|
fluxResult = await fluxDataWriter(qu)
|
2026-03-02 21:46:51 +01:00
|
|
|
match fluxResult:
|
|
|
|
|
case 1:
|
|
|
|
|
print("could not insert")
|
|
|
|
|
case 2:
|
|
|
|
|
print("Error with initializing Inxlux variables")
|
|
|
|
|
case _:
|
|
|
|
|
print("Inserted to InfluxDB")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(e)
|
|
|
|
|
finally:
|
|
|
|
|
inputQueue.task_done()
|