MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / upsert_edge

Function upsert_edge

skills/wiki-store/scripts/wiki_db.py:406–431  ·  view source on GitHub ↗
(
    *,
    user_id: str,
    src_id: str,
    dst_id: str,
    relation: str,
    weight: float = 1.0,
    metadata: Optional[Dict[str, Any]] = None,
)

Source from the content-addressed store, hash-verified

404
405
406def upsert_edge(
407 *,
408 user_id: str,
409 src_id: str,
410 dst_id: str,
411 relation: str,
412 weight: float = 1.0,
413 metadata: Optional[Dict[str, Any]] = None,
414) -> int:
415 init_wiki_schema()
416 conn = db_ops.get_connection()
417 cursor = conn.cursor()
418 cursor.execute(
419 """
420 INSERT INTO wiki_edges (user_id, src_id, dst_id, relation, weight, metadata_json)
421 VALUES (?, ?, ?, ?, ?, ?)
422 ON CONFLICT(user_id, src_id, dst_id, relation) DO UPDATE SET
423 weight=excluded.weight,
424 metadata_json=excluded.metadata_json
425 """,
426 (user_id, src_id, dst_id, relation, float(weight), _json_dumps(metadata)),
427 )
428 conn.commit()
429 edge_id = int(cursor.lastrowid or 0)
430 conn.close()
431 return edge_id
432
433
434def upsert_citation(

Callers

nothing calls this directly

Calls 5

init_wiki_schemaFunction · 0.85
_json_dumpsFunction · 0.85
cursorMethod · 0.80
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected