BE: direct DB access removed where possible

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2025-12-25 10:30:42 +11:00
parent a8cac85a11
commit d119708538
4 changed files with 24 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
import sqlite3
import sys
import os
# Connect to the database using environment variable
@@ -6,7 +6,14 @@ db_path = os.path.join(
os.getenv('NETALERTX_DB', '/data/db'),
'app.db'
)
conn = sqlite3.connect(db_path)
# Register NetAlertX directories
INSTALL_PATH = os.getenv("NETALERTX_APP", "/app")
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from database import get_temp_db_connection # noqa: E402 [flake8 lint suppression]
conn = get_temp_db_connection()
cursor = conn.cursor()
# Get the names of all tables (excluding SQLite internal tables)