salescrm/b/cpcc/utils/template_code.py
2025-10-27 15:50:44 +08:00

43 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
# @Time: 2025/05/19 9:41
import asyncio
from sqlor.dbpools import DBPools
from appPublic.jsonConfig import getConfig
async def tmp(ns={}):
"""
:param ns:
:return:
"""
# 增删改查用到的数据格式dict
ns = {
'id': ns.get('id'),
"clustercode": ns.get('clustercode'),
}
db = DBPools()
async with db.sqlorContext('kboss') as sor:
try:
# sor.C sor.R sor.U
r_resutl = await sor.R('表名', nss)
#执行原生sql
y_sql = """update table set ... %s""" % ns['id']
result = await sor.sqlExe(y_sql, {})
# 返回默认格式
return {'status': True, 'msg': '操作成功', 'data': r}
except Exception as e:
# TODO 日志等操作
raise e
return {'status': False, 'msg': '操作失败'}
if __name__ == '__main__':
p = '路径:/kboss_code/'
config = getConfig(p)
DBPools(config.databases)
loop = asyncio.get_event_loop()
print(loop.run_until_complete(tmp()))