agent_m/agentm/logic/db.py
mscrnt 5179d425fc Add initial project structure and core functionality for Agent M
- Created .gitignore to exclude virtual environment, logs, and database files.
- Updated README.md with project description, features, folder structure, requirements, and usage instructions.
- Implemented versioning and developer ID in agentm/__init__.py.
- Developed main application logic in agentm/app.py, including credential handling and screen navigation.
- Added database initialization and ROM management logic in agentm/logic/db.py and agentm/logic/db_functions.py.
- Integrated DIAMBRA login functionality in agentm/logic/diambra_login.py.
- Created ROM verification and caching system in agentm/logic/roms.py.
- Designed user interface components for home and login screens in agentm/views/home.py and agentm/views/login.py.
- Added logging utility in agentm/utils/logger.py for better debugging and tracking.
- Included assets such as game images, styles, and logos.
- Updated requirements.txt with necessary dependencies for the project.
2025-05-20 23:20:29 -07:00

27 lines
821 B
Python

import sqlite3
from pathlib import Path
CACHE_DB_PATH = Path("agentm/data/agentM.db")
CACHE_DB_PATH.parent.mkdir(parents=True, exist_ok=True)
def get_db_conn():
return sqlite3.connect(CACHE_DB_PATH)
def initialize_database():
with get_db_conn() as conn:
conn.execute("""
CREATE TABLE IF NOT EXISTS roms (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
rom_file TEXT NOT NULL UNIQUE,
game_id TEXT NOT NULL,
sha256 TEXT,
difficulty_min INTEGER,
difficulty_max INTEGER,
characters TEXT,
keywords TEXT,
verified BOOLEAN NOT NULL DEFAULT 0,
verified_at TEXT
);
""")
conn.commit()