bugfix
This commit is contained in:
parent
fb8153cc3a
commit
c3d7ffc118
@ -70,7 +70,8 @@ class SqlorPool:
|
|||||||
yielded_sqlor = None
|
yielded_sqlor = None
|
||||||
for s in sqlors:
|
for s in sqlors:
|
||||||
if not s.used:
|
if not s.used:
|
||||||
if self.test_sqlor(s):
|
flg = self.test_sqlor(s):
|
||||||
|
if flg:
|
||||||
yielded_sqlor = s
|
yielded_sqlor = s
|
||||||
else:
|
else:
|
||||||
self.sqlors = [ x for x in self.sqlors if x != s ]
|
self.sqlors = [ x for x in self.sqlors if x != s ]
|
||||||
@ -118,7 +119,9 @@ class DBPools:
|
|||||||
sqlor = None
|
sqlor = None
|
||||||
try:
|
try:
|
||||||
async with pool.context() as sqlor:
|
async with pool.context() as sqlor:
|
||||||
|
sqlor.enter()
|
||||||
yield sqlor
|
yield sqlor
|
||||||
|
sqlor.exit()
|
||||||
if sqlor and sqlor.dataChanged:
|
if sqlor and sqlor.dataChanged:
|
||||||
await sqlor.commit()
|
await sqlor.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -152,10 +152,20 @@ WHERE
|
|||||||
"""
|
"""
|
||||||
dbdesc = self.dbdesc
|
dbdesc = self.dbdesc
|
||||||
self.conn = await aiomysql.connect(**dbdesc)
|
self.conn = await aiomysql.connect(**dbdesc)
|
||||||
self.cur = await self.conn.cursor()
|
|
||||||
self.dbname = dbdesc.get('db')
|
self.dbname = dbdesc.get('db')
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
await self.cursor.close()
|
await self.cursor.close()
|
||||||
await self.conn.close()
|
await self.conn.close()
|
||||||
|
|
||||||
|
async def enter(self):
|
||||||
|
self.cur = await self.conn.cursor()
|
||||||
|
|
||||||
|
async def exit(self):
|
||||||
|
try:
|
||||||
|
await self.cur.fetchall()
|
||||||
|
self.cur.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
self.cur = None
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,12 @@ class SQLor(object):
|
|||||||
self.dataChanged = False
|
self.dataChanged = False
|
||||||
self.metadatas={}
|
self.metadatas={}
|
||||||
|
|
||||||
|
async def enter(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def exit(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def unpassword(self):
|
def unpassword(self):
|
||||||
if self.dbdesc.password:
|
if self.dbdesc.password:
|
||||||
key=getConfig().password_key
|
key=getConfig().password_key
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user