Refactor database management and schema initialization
- Removed the old npc_memory.db file. - Updated time.txt with a new timestamp. - Refactored transaction recording in bank_functions.py to use parameterized queries. - Enhanced DatabaseManager in sql_commands.py to support singleton pattern and improved table creation logic. - Added methods for sanitizing SQL identifiers and parsing insert columns for upsert operations. - Improved error handling and connection management in execute_query, fetch_one, fetch_all, and fetch_as_dataframe methods. - Introduced a new bootstrap_database.py script for initializing the database schema. - Updated app.py to use the new initialize_database function for database management.
This commit is contained in:
Binary file not shown.
+3
-3
@@ -4,10 +4,10 @@ import os
|
||||
if __package__ is None or __package__ == "":
|
||||
# Running as __main__ (e.g. python web/app.py)
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
from utils.sql_commands import DatabaseManager
|
||||
from utils.sql_commands import DatabaseManager, initialize_database
|
||||
else:
|
||||
# Imported as a module (e.g. from bot.py)
|
||||
from utils.sql_commands import DatabaseManager
|
||||
from utils.sql_commands import DatabaseManager, initialize_database
|
||||
|
||||
import os
|
||||
import requests
|
||||
@@ -21,7 +21,7 @@ load_dotenv()
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.getenv("SECRET_KEY")
|
||||
db = DatabaseManager()
|
||||
db = initialize_database()
|
||||
|
||||
# Ensure required environment variables are loaded
|
||||
DISCORD_CLIENT_ID = os.getenv("DISCORD_CLIENT_ID")
|
||||
|
||||
Reference in New Issue
Block a user