Alibrown commited on
Commit
2089b25
·
verified ·
1 Parent(s): 948a289

Update app/db_sync.py

Browse files
Files changed (1) hide show
  1. app/db_sync.py +3 -11
app/db_sync.py CHANGED
@@ -312,26 +312,18 @@ def set_psql_writer(writer_fn) -> None:
312
 
313
 
314
  async def persist(table: str, data: dict) -> None:
315
- """
316
- Write data from app/* to PostgreSQL via Guardian-injected writer.
317
- Called by tools.py for provider_type = 'persist'.
318
- Graceful degradation: raises RuntimeError if no DB configured.
319
-
320
- Args:
321
- table: Target PostgreSQL table name.
322
- data: Dict to persist — stored as JSONB column 'payload'.
323
- """
324
  if not _psql_writer:
325
  raise RuntimeError("No PostgreSQL writer — DATABASE_URL not configured.")
326
 
327
  from datetime import datetime, timezone
328
  now = datetime.now(timezone.utc).isoformat()
329
 
 
 
330
  sql = f"INSERT INTO {table} (payload, created_at) VALUES ($1::jsonb, $2)"
331
- await _psql_writer(sql, json.dumps(data), now, fetch_method="execute")
332
  logger.info(f"Persisted to PostgreSQL table '{table}'.")
333
 
334
-
335
  # =============================================================================
336
  # Direct execution guard
337
  # =============================================================================
 
312
 
313
 
314
  async def persist(table: str, data: dict) -> None:
 
 
 
 
 
 
 
 
 
315
  if not _psql_writer:
316
  raise RuntimeError("No PostgreSQL writer — DATABASE_URL not configured.")
317
 
318
  from datetime import datetime, timezone
319
  now = datetime.now(timezone.utc).isoformat()
320
 
321
+ # asyncpg Pool.execute() Signatur: execute(query, *args)
322
+ # kein fetch_method Parameter — direkt aufrufen
323
  sql = f"INSERT INTO {table} (payload, created_at) VALUES ($1::jsonb, $2)"
324
+ await _psql_writer(sql, json.dumps(data), now)
325
  logger.info(f"Persisted to PostgreSQL table '{table}'.")
326
 
 
327
  # =============================================================================
328
  # Direct execution guard
329
  # =============================================================================