From eec5507b5d98097d45ef2a914a29808af123ad9c Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 28 Nov 2019 14:58:06 +0800 Subject: [PATCH] add runSQL, runSQLPaging function --- sqlor/dbpools.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/sqlor/dbpools.py b/sqlor/dbpools.py index 0c43ee1..426019b 100644 --- a/sqlor/dbpools.py +++ b/sqlor/dbpools.py @@ -18,7 +18,6 @@ from .mysqlor import MySqlor from .aiomysqlor import AioMysqlor from .aiopostgresqlor import AioPostgresqlor - def sqlorFactory(dbdesc): driver = dbdesc.get('driver',dbdesc) def findSubclass(name,klass): @@ -370,3 +369,29 @@ class DBPools: return ret return await _getTableForignKeys(dbname,{},tblname,**kw) +async def runSQL(dbname,sql,ns={},sor=None): + pool = DBPools() + @pool.runSQL + async def desc(dbname,ns,*args,**kw): + return { + "sql_string":sql + } + kw = { + 'sor':sor + } + x = await desc(dbname,ns,**kw) + return x + +async def runSQLPaging(dbname,sql,ns={},sor=None): + pool = DBPools() + @pool.runSQLPaging + async def desc(dbname,ns,*args,**kw): + return { + "sql_string":sql + } + kw = { + "sor":sor + } + x = await desc(dbname, ns, **kw) + return x +