db = DBPools() orderid = params_kw.get('orderid', 'JsNa3vy6u4XdeBCVq7nfD') async with db.sqlorContext('kboss') as sor: await order2bill(orderid, sor) bills = await sor.sqlExe("select * from bill where orderid=${orderid}$", {'orderid':orderid}) if len(bills) == 0: print('bill not found') return Error(555, msg='bill not found') print('accounting ..............') for b in bills: ba = BillAccounting(b) ret = await ba.accounting(sor)