bugfix
This commit is contained in:
parent
2f89d1e4b9
commit
d5a53f2e53
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from traceback import print_exc
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
@ -198,12 +199,14 @@ class DBPools:
|
|||||||
sqlor = await self.getSqlor(name)
|
sqlor = await self.getSqlor(name)
|
||||||
try:
|
try:
|
||||||
yield sqlor
|
yield sqlor
|
||||||
except:
|
except Exception as e:
|
||||||
|
print_exc()
|
||||||
|
print('Exeception=',e)
|
||||||
if sqlor and sqlor.dataChanged:
|
if sqlor and sqlor.dataChanged:
|
||||||
sqlor.rollback()
|
await sqlor.rollback()
|
||||||
finally:
|
finally:
|
||||||
if sqlor and sqlor.dataChanged:
|
if sqlor and sqlor.dataChanged:
|
||||||
sqlor.commit()
|
await sqlor.commit()
|
||||||
await self.freeSqlor(sqlor)
|
await self.freeSqlor(sqlor)
|
||||||
|
|
||||||
async def _aquireConn(self,dbname):
|
async def _aquireConn(self,dbname):
|
||||||
|
22
sqlor/sor.py
22
sqlor/sor.py
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from asyncio import coroutine
|
||||||
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
|
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
|
||||||
import sys
|
import sys
|
||||||
import codecs
|
import codecs
|
||||||
@ -393,12 +394,9 @@ class SQLor(object):
|
|||||||
await self.execute(desc,NS,None)
|
await self.execute(desc,NS,None)
|
||||||
|
|
||||||
async def sqlExe(self,sql,ns):
|
async def sqlExe(self,sql,ns):
|
||||||
desc = {
|
|
||||||
"sql_string":sql
|
|
||||||
}
|
|
||||||
ret = []
|
ret = []
|
||||||
await self.execute(desc,ns,
|
await self.execute(sql,ns,
|
||||||
callback=lambda(x):ret.append(DictObject(**x)))
|
callback=lambda x:ret.append(DictObject(**x)))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
async def tables(self):
|
async def tables(self):
|
||||||
@ -481,10 +479,16 @@ class SQLor(object):
|
|||||||
desc['validation'].append(idx)
|
desc['validation'].append(idx)
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
def rollback(self):
|
async def rollback(self):
|
||||||
self.conn.rollback()
|
if self.async_mode:
|
||||||
|
await self.conn.rollback()
|
||||||
|
else:
|
||||||
|
self.conn.rollback()
|
||||||
self.dataChanged = False
|
self.dataChanged = False
|
||||||
|
|
||||||
def commit(self):
|
async def commit(self):
|
||||||
self.conn.commit()
|
if self.async_mode:
|
||||||
|
await self.conn.commit()
|
||||||
|
else:
|
||||||
|
self.conn.commit()
|
||||||
self.datachanged = False
|
self.datachanged = False
|
||||||
|
Loading…
Reference in New Issue
Block a user