import sqlite3 | |
def init_db(): | |
conn = sqlite3.connect("memory.db") | |
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("memory.db") | |
cursor = conn.cursor() | |
cursor.execute( | |
"INSERT INTO agent_logs (agent, action, result) VALUES (?, ?, ?)", | |
(agent, action, result) | |
) | |
conn.commit() | |
conn.close() | |