Download memory/database.py from mgbam/AICEO: direct link, hf CLI and curl.
- Browser
- Download file 781 Bytes
-
https://huggingface.co/spaces/mgbam/AICEO/resolve/b7b397ecdd111537d694f36b57e70e5cb5cd00d2/memory/database.py
- Command line
-
hf download hf://spaces/mgbam/AICEO@b7b397ecdd111537d694f36b57e70e5cb5cd00d2/memory/database.py
-
curl -L -o database.py https://huggingface.co/spaces/mgbam/AICEO/resolve/b7b397ecdd111537d694f36b57e70e5cb5cd00d2/memory/database.py
781 Bytes
| import sqlite3 | |
| import os | |
| # Define safe path for Hugging Face Docker environment | |
| DB_PATH = os.path.join("/tmp", "memory.db") | |
| def init_db(): | |
| conn = sqlite3.connect(DB_PATH) | |
| cursor = conn.cursor() | |
| cursor.execute( | |
| """CREATE TABLE IF NOT EXISTS agent_logs ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| agent TEXT, | |
| action TEXT, | |
| result TEXT, | |
| timestamp DATETIME DEFAULT CURRENT_TIMESTAMP | |
| )""" | |
| ) | |
| conn.commit() | |
| conn.close() | |
| def log_action(agent, action, result): | |
| conn = sqlite3.connect(DB_PATH) | |
| cursor = conn.cursor() | |
| cursor.execute( | |
| "INSERT INTO agent_logs (agent, action, result) VALUES (?, ?, ?)", | |
| (agent, action, result) | |
| ) | |
| conn.commit() | |
| conn.close() | |