mgbam commited on
Commit
c28b1fc
·
verified ·
1 Parent(s): 9644187

Update memory/database.py

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