"""Module to check for the database.""" import os import yaml from custom_functions.database.cache_to_db_mariadb import ( create_database as create_mariadb_database, ) from custom_functions.database.cache_to_db_sqlite import ( create_database as create_sqlite_database, ) from custom_functions.database.user_db import create_user_database def check_for_sqlite_database(): """Check for the SQLite database.""" with open( os.path.join(os.getcwd(), "configs", "config.yaml"), "r", encoding="utf-8" ) as file: config = yaml.safe_load(file) if os.path.exists(os.path.join(os.getcwd(), "databases", "key_cache.db")): return if config["database_type"].lower() == "sqlite": create_sqlite_database() return return def check_for_user_database(): """Check for the user database.""" if os.path.exists(os.path.join(os.getcwd(), "databases", "users.db")): return create_user_database() def check_for_mariadb_database(): """Check for the MariaDB database.""" with open( os.path.join(os.getcwd(), "configs", "config.yaml"), "r", encoding="utf-8" ) as file: config = yaml.safe_load(file) if config["database_type"].lower() == "mariadb": create_mariadb_database() return return def check_for_sql_database(): """Check for the SQL database.""" check_for_sqlite_database() check_for_mariadb_database() check_for_user_database()