From ec3e76181c493f994984582ede5bf7dca5ddbf78 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 29 Jul 2024 15:44:44 +0200 Subject: [PATCH] ADD /report --- main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index fd9130a..7159898 100644 --- a/main.py +++ b/main.py @@ -343,15 +343,15 @@ async def reporting(get: CL.CL_REPORTING,api_key: APIKey = Depends(auth.get_api_ user_check = database(f"SELECT username from users where username = '{get.username}'","Kunden","") if not user_check: print("User not exist") - next - entry = database(f"SELECT s.customer_ID,s.service_ID from `server` s where s.privat_ipaddress LIKE '%{get.ipaddress}%'","Kunden","") - customer_ID = entry[0][0] - service_ID = entry[0][1] - reportingdate = datetime.now() - reportingdate = reportingdate.strftime("%Y-%m-%d %H:%M:%S") - print(reportingdate) - #database(f"INSERT INTO `Kunden.services.reporting` (username,service_ID,customer_ID,reportingdate,lastaccess) VALUES ('{get.username}','{service_ID}','{customer_ID}',{reportingdate}',{get.lastaccess}'","","") - print(f"{service_ID} - {customer_ID}") + else: + entry = database(f"SELECT s.customer_ID,s.service_ID from `server` s where s.privat_ipaddress LIKE '%{get.ipaddress}%'","Kunden","") + customer_ID = entry[0][0] + service_ID = entry[0][1] + reportingdate = datetime.now() + reportingdate = reportingdate.strftime("%Y-%m-%d %H:%M:%S") + print(reportingdate) + #database(f"INSERT INTO `Kunden.services.reporting` (username,service_ID,customer_ID,reportingdate,lastaccess) VALUES ('{get.username}','{service_ID}','{customer_ID}',{reportingdate}',{get.lastaccess}'","","") + print(f"{service_ID} - {customer_ID}") ## Startet den API-Server