Add health check API, logging setup, and environment variable support; update requirements and .gitignore
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import mariadb
|
||||
import logging
|
||||
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
#Logging
|
||||
|
||||
@@ -104,3 +105,17 @@ def delete(cloth_type):
|
||||
cursor.execute("DELETE FROM luggage WHERE clothes = ?;", (cloth_type,))
|
||||
logging.critical(f"{cloth_type} was deleted")
|
||||
connection.commit()
|
||||
|
||||
|
||||
|
||||
#using .env
|
||||
load_dotenv()
|
||||
db_name = os.getenv("DB_NAME")
|
||||
db_psswd = os.getenv("DB_PASSWORD")
|
||||
db_user = os.getenv("DB_USER")
|
||||
db_port = os.getenv("DB_PORT") or "3306"
|
||||
db_host = os.getenv("DB_HOST")
|
||||
if db_host == None:
|
||||
logging.error("no hostname provided")
|
||||
os._exit(1)
|
||||
connect(db_user, db_psswd, db_host, int(db_port), db_name)
|
||||
|
||||
Reference in New Issue
Block a user