这是我使用self.engine.dispose()
时的代码,它给了我异常,所以我应该使用这个del self.engine
它工作正常,请给我任何建议。你知道吗
class MSSqlAlchemyConn(object):
def __init__(self, connection_obj):
"""
Constructor for SQLAlchemy.
"""
try:
# connection string
# example: mysql+mysqldb://[mysqluser]:[password]@[host]:[port]/[db_name]
constr = "mssql+pymssql://%s:%s@%s/%s" % (connection_obj['USER'], connection_obj['PASSWORD'],
connection_obj['HOST'],
connection_obj['DATABASE'])
self.engine = create_engine(constr, echo=False)
except Exception as e:
logger.error(e)
def __del__(self):
if self.engine is not None:
del self.engine
目前没有回答
相关问题 更多 >
编程相关推荐