This commit is contained in:
yumoqing 2025-10-20 10:17:51 +08:00
parent b56afa920e
commit 92f2857ce6
2 changed files with 3 additions and 4 deletions

View File

@ -28,7 +28,7 @@ SQLOR is a database api for python3, it is base on the python's DBAPI2
``` ```
import asyncio import asyncio
from sqlor.dbpools import DBPools from sqlor.dbpools import DBPools, sqlorContext
dbs={ dbs={
"aiocfae":{ "aiocfae":{
@ -72,8 +72,7 @@ loop = asyncio.get_event_loop()
pool = DBPools(dbs,loop=loop) pool = DBPools(dbs,loop=loop)
async def testfunc(): async def testfunc():
db = DBPools() async with sqlorContext('stock') as sor:
async with db.sqlorContext('stock') as sor:
# start a transaction # start a transaction
# if exception happended, all change to database will rollback # if exception happended, all change to database will rollback
# else will commit # else will commit

View File

@ -80,7 +80,7 @@ class SQLor(object):
self.sqlts = sqlts self.sqlts = sqlts
self.sqlvp = sqlvp self.sqlvp = sqlvp
self.sqlvs = sqlvs self.sqlvs = sqlvs
self.dbdesc = dbdesc self.dbdesc = dbdesc.copy()
self.unpassword() self.unpassword()
self.dbname = None self.dbname = None
self.writer = None self.writer = None