mgbam commited on
Commit
df6f5ec
·
verified ·
1 Parent(s): f761f01

Update memory/database.py

Browse files
Files changed (1) hide show
  1. memory/database.py +9 -11
memory/database.py CHANGED
@@ -1,30 +1,28 @@
1
- # memory/database.py
2
-
3
  import sqlite3
4
  import os
5
 
6
- DB_PATH = os.path.join("/tmp", "memory.db")
7
 
8
  def init_db():
9
  conn = sqlite3.connect(DB_PATH)
10
- cursor = conn.cursor()
11
- cursor.execute("""
12
- CREATE TABLE IF NOT EXISTS agent_logs (
13
  id INTEGER PRIMARY KEY AUTOINCREMENT,
14
  agent TEXT,
15
  action TEXT,
16
  result TEXT,
17
- timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
18
  )
19
  """)
20
  conn.commit()
21
  conn.close()
22
 
23
- def log_action(agent: str, action: str, result: str):
24
  conn = sqlite3.connect(DB_PATH)
25
- cursor = conn.cursor()
26
- cursor.execute(
27
- "INSERT INTO agent_logs (agent, action, result) VALUES (?, ?, ?)",
28
  (agent, action, result)
29
  )
30
  conn.commit()
 
 
 
1
  import sqlite3
2
  import os
3
 
4
+ DB_PATH = os.path.join("/mnt/data", "memory.db")
5
 
6
  def init_db():
7
  conn = sqlite3.connect(DB_PATH)
8
+ c = conn.cursor()
9
+ c.execute("""
10
+ CREATE TABLE IF NOT EXISTS memory_logs (
11
  id INTEGER PRIMARY KEY AUTOINCREMENT,
12
  agent TEXT,
13
  action TEXT,
14
  result TEXT,
15
+ timestamp TEXT
16
  )
17
  """)
18
  conn.commit()
19
  conn.close()
20
 
21
+ def log_memory(agent: str, action: str, result: str):
22
  conn = sqlite3.connect(DB_PATH)
23
+ c = conn.cursor()
24
+ c.execute(
25
+ "INSERT INTO memory_logs (agent, action, result, timestamp) VALUES (?,?,?,datetime('now'))",
26
  (agent, action, result)
27
  )
28
  conn.commit()