This commit is contained in:
yumoqing 2025-10-19 16:52:34 +08:00
parent 5c58c04440
commit 4d86499372

View File

@ -237,11 +237,13 @@ class SQLor(object):
async def cur_execute(self, cur, sql, ns): async def cur_execute(self, cur, sql, ns):
if inspect.iscoroutinefunction(cur.execute): if inspect.iscoroutinefunction(cur.execute):
debug('-------coroutine-------')
return await cur.execute(sql, ns) return await cur.execute(sql, ns)
f = awaitify(cur.execute) f = awaitify(cur.execute)
debug('------function--------')
return await f(sql, ns) return await f(sql, ns)
async def runVarSQL(self,cursor,sql,NS): async def runVarSQL(self, cursor, sql, NS):
""" """
using a opened cursor to run a SQL statment with variable, the variable is setup in NS namespace using a opened cursor to run a SQL statment with variable, the variable is setup in NS namespace
return a cursor with data return a cursor with data
@ -250,7 +252,7 @@ class SQLor(object):
datas = self.dataConvert(datas) datas = self.dataConvert(datas)
try: try:
return await self.cur_execute(cursor, return await self.cur_execute(cursor,
sql, markedSQL,
datas) datas)
except Exception as e: except Exception as e:
@ -310,7 +312,7 @@ class SQLor(object):
async def execute(self, sql, value): async def execute(self, sql, value):
sqltype = self.getSqlType(sql) sqltype = self.getSqlType(sql)
cur = self.cursor() cur = self.cursor()
ret = await self.runVarSQL(cur,sql,value) ret = await self.runVarSQL(cur, sql, value)
if sqltype == 'dml': if sqltype == 'dml':
self.dataChanged = True self.dataChanged = True
return ret return ret