fix: use get_sor_context(env, 'tenant') — proper sqlor/dspy cross-db pattern
This commit is contained in:
parent
3be62ba01c
commit
3a5b9068d9
@ -4,7 +4,7 @@ for k,v in ns.items():
|
||||
ns[k] = None
|
||||
if not ns.get("id"):
|
||||
ns["id"] = getID()
|
||||
db = DBPools()
|
||||
async with db.sqlorContext("pipeline") as sor:
|
||||
env = request._run_ns
|
||||
async with get_sor_context(env, "tenant") as sor:
|
||||
await sor.C("tenant_domain", ns)
|
||||
return {"status": "ok"}
|
||||
|
||||
@ -3,7 +3,7 @@ rid = ns.get("id")
|
||||
if not rid:
|
||||
return {"status": "error", "message": "id required"}
|
||||
ns["rid"] = rid
|
||||
db = DBPools()
|
||||
async with db.sqlorContext("pipeline") as sor:
|
||||
env = request._run_ns
|
||||
async with get_sor_context(env, "tenant") as sor:
|
||||
await sor.sqlExe("DELETE FROM tenant_domain WHERE id=${rid}$", ns)
|
||||
return {"status": "ok"}
|
||||
|
||||
@ -7,8 +7,8 @@ pagerows = int(ns.get("rows", 20))
|
||||
offset = (page - 1) * pagerows
|
||||
ns["pagerows"] = pagerows
|
||||
ns["offset"] = offset
|
||||
db = DBPools()
|
||||
async with db.sqlorContext("pipeline") as sor:
|
||||
env = request._run_ns
|
||||
async with get_sor_context(env, "tenant") as sor:
|
||||
recs = await sor.sqlExe("SELECT count(*) as total FROM tenant_domain", {})
|
||||
total = recs[0].total if recs else 0
|
||||
recs = await sor.sqlExe("SELECT * FROM tenant_domain ORDER BY created_at desc LIMIT ${pagerows}$ OFFSET ${offset}$", ns)
|
||||
|
||||
@ -6,7 +6,7 @@ rid = ns.get("id")
|
||||
if not rid:
|
||||
return {"status": "error", "message": "id required"}
|
||||
ns["rid"] = rid
|
||||
db = DBPools()
|
||||
async with db.sqlorContext("pipeline") as sor:
|
||||
env = request._run_ns
|
||||
async with get_sor_context(env, "tenant") as sor:
|
||||
await sor.sqlExe("UPDATE tenant_domain SET domain=${domain}$, resellerid=${resellerid}$, orgid=${orgid}$, status=${status}$ WHERE id=${rid}$", ns)
|
||||
return {"status": "ok"}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user