Commit 8773d39e authored by pengxiong's avatar pengxiong

连接池

parent 4f90d69d
...@@ -93,8 +93,7 @@ class TAMP_SQL(object): ...@@ -93,8 +93,7 @@ class TAMP_SQL(object):
def __init__(self, db_engine): def __init__(self, db_engine):
# 创建DBSession类型: # 创建DBSession类型:
self.db_engine = db_engine self.DBSession = scoped_session(sessionmaker(bind=db_engine))
self.DBSession = scoped_session(sessionmaker(bind=self.db_engine))
self.session = self.DBSession() self.session = self.DBSession()
def __enter__(self): def __enter__(self):
...@@ -106,5 +105,4 @@ class TAMP_SQL(object): ...@@ -106,5 +105,4 @@ class TAMP_SQL(object):
except: except:
self.session.rollback() self.session.rollback()
finally: finally:
self.session.close() self.session.remove()
self.db_engine.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment