sql

parent 214c73bb
...@@ -74,3 +74,28 @@ logging.basicConfig(level=logging.INFO, ...@@ -74,3 +74,28 @@ logging.basicConfig(level=logging.INFO,
datefmt=config[env]['log']['datefmt'] datefmt=config[env]['log']['datefmt']
) )
class TAMP_SQL(object):
"""[sqlalchemy 封装]
Args:
object ([type]): [description]
Returns:
[type]: [description]
"""
def __init__(self, db_engine):
# 创建DBSession类型:
self.DBSession = scoped_session(sessionmaker(bind=db_engine))
self.session = self.DBSession()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
try:
self.session.commit()
except:
self.session.rollback()
finally:
self.session.close()
\ No newline at end of file
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