This commit is contained in:
yumoqing 2019-05-22 20:07:45 +08:00
parent 12be14d8c3
commit 3b24b1f6ab

View File

@ -207,11 +207,15 @@ class DBPools:
def runSQL(self,func): def runSQL(self,func):
@wraps(func) @wraps(func)
async def wrap_func(dbname,NS,callback,**kw): async def wrap_func(dbname,NS,callback=None,**kw):
sor = await self.getSqlor(dbname) sor = await self.getSqlor(dbname)
try: try:
desc = func(dbname,NS,callback,**kw) desc = func(dbname,NS,callback=callback,**kw)
ret = await sor.runSQL(desc,NS,callback,**kw) ret = await sor.runSQL(desc,NS,callback,**kw)
if NS.get('dummy'):
return NS['dummy']
else:
return []
except Exception as e: except Exception as e:
print('error:',e) print('error:',e)
raise e raise e
@ -276,6 +280,13 @@ class DBPools:
return ret return ret
return await _getTablePrimaryKey(None,dbname,tblname) return await _getTablePrimaryKey(None,dbname,tblname)
async def getTableIndexes(self,dbname,tblname):
@self.inSqlor
async def _getTablePrimaryKey(sor,dbname,tblname):
ret = await sor.indexes(tblname)
return ret
return await _getTablePrimaryKey(None,dbname,tblname)
async def getTableForignKeys(self,dbname,tblname): async def getTableForignKeys(self,dbname,tblname):
@self.inSqlor @self.inSqlor
async def _getTableForignKeys(sor,dbname,tblname): async def _getTableForignKeys(sor,dbname,tblname):