MikelWL commited on
Commit
d2c64aa
·
1 Parent(s): d89cff8

Fix: support older aiosqlite without execute_fetch*

Browse files
Files changed (1) hide show
  1. backend/storage/sqlite_run_store.py +13 -7
backend/storage/sqlite_run_store.py CHANGED
@@ -183,7 +183,7 @@ class SQLiteRunStore:
183
  async with aiosqlite.connect(self.db_path) as db:
184
  await db.execute("PRAGMA foreign_keys=ON;")
185
  if mode:
186
- rows = await db.execute_fetchall(
187
  """
188
  SELECT run_id, mode, status, created_at, ended_at, title, input_summary
189
  FROM runs
@@ -194,7 +194,7 @@ class SQLiteRunStore:
194
  (mode, limit, offset),
195
  )
196
  else:
197
- rows = await db.execute_fetchall(
198
  """
199
  SELECT run_id, mode, status, created_at, ended_at, title, input_summary
200
  FROM runs
@@ -203,6 +203,7 @@ class SQLiteRunStore:
203
  """,
204
  (limit, offset),
205
  )
 
206
 
207
  return [
208
  RunSummary(
@@ -220,7 +221,7 @@ class SQLiteRunStore:
220
  async def get_run(self, run_id: str) -> Optional[RunRecord]:
221
  async with aiosqlite.connect(self.db_path) as db:
222
  await db.execute("PRAGMA foreign_keys=ON;")
223
- row = await db.execute_fetchone(
224
  """
225
  SELECT run_id, mode, status, created_at, ended_at, title, input_summary, config_json, sealed_at
226
  FROM runs
@@ -228,10 +229,11 @@ class SQLiteRunStore:
228
  """,
229
  (run_id,),
230
  )
 
231
  if not row:
232
  return None
233
 
234
- message_rows = await db.execute_fetchall(
235
  """
236
  SELECT message_index, role, persona_label, content, timestamp
237
  FROM run_messages
@@ -240,7 +242,9 @@ class SQLiteRunStore:
240
  """,
241
  (run_id,),
242
  )
243
- analysis_rows = await db.execute_fetchall(
 
 
244
  """
245
  SELECT analysis_key, result_json
246
  FROM run_analyses
@@ -248,7 +252,9 @@ class SQLiteRunStore:
248
  """,
249
  (run_id,),
250
  )
251
- snapshot_rows = await db.execute_fetchall(
 
 
252
  """
253
  SELECT role, persona_id, persona_version_id, snapshot_json
254
  FROM run_persona_snapshots
@@ -256,6 +262,7 @@ class SQLiteRunStore:
256
  """,
257
  (run_id,),
258
  )
 
259
 
260
  messages: List[Dict[str, Any]] = []
261
  for (idx, role, persona, content, ts) in message_rows:
@@ -307,4 +314,3 @@ class SQLiteRunStore:
307
  analyses=analyses,
308
  persona_snapshots=persona_snapshots,
309
  )
310
-
 
183
  async with aiosqlite.connect(self.db_path) as db:
184
  await db.execute("PRAGMA foreign_keys=ON;")
185
  if mode:
186
+ cursor = await db.execute(
187
  """
188
  SELECT run_id, mode, status, created_at, ended_at, title, input_summary
189
  FROM runs
 
194
  (mode, limit, offset),
195
  )
196
  else:
197
+ cursor = await db.execute(
198
  """
199
  SELECT run_id, mode, status, created_at, ended_at, title, input_summary
200
  FROM runs
 
203
  """,
204
  (limit, offset),
205
  )
206
+ rows = await cursor.fetchall()
207
 
208
  return [
209
  RunSummary(
 
221
  async def get_run(self, run_id: str) -> Optional[RunRecord]:
222
  async with aiosqlite.connect(self.db_path) as db:
223
  await db.execute("PRAGMA foreign_keys=ON;")
224
+ cursor = await db.execute(
225
  """
226
  SELECT run_id, mode, status, created_at, ended_at, title, input_summary, config_json, sealed_at
227
  FROM runs
 
229
  """,
230
  (run_id,),
231
  )
232
+ row = await cursor.fetchone()
233
  if not row:
234
  return None
235
 
236
+ cursor = await db.execute(
237
  """
238
  SELECT message_index, role, persona_label, content, timestamp
239
  FROM run_messages
 
242
  """,
243
  (run_id,),
244
  )
245
+ message_rows = await cursor.fetchall()
246
+
247
+ cursor = await db.execute(
248
  """
249
  SELECT analysis_key, result_json
250
  FROM run_analyses
 
252
  """,
253
  (run_id,),
254
  )
255
+ analysis_rows = await cursor.fetchall()
256
+
257
+ cursor = await db.execute(
258
  """
259
  SELECT role, persona_id, persona_version_id, snapshot_json
260
  FROM run_persona_snapshots
 
262
  """,
263
  (run_id,),
264
  )
265
+ snapshot_rows = await cursor.fetchall()
266
 
267
  messages: List[Dict[str, Any]] = []
268
  for (idx, role, persona, content, ts) in message_rows:
 
314
  analyses=analyses,
315
  persona_snapshots=persona_snapshots,
316
  )