diff --git a/extras/context_helper/sfpark_contextmanager.py b/extras/context_helper/sfpark_contextmanager.py index c9b7288..bf58aee 100644 --- a/extras/context_helper/sfpark_contextmanager.py +++ b/extras/context_helper/sfpark_contextmanager.py @@ -1,21 +1,21 @@ import logging class SessionContextManager: - def __init__(self, builder_object): - self.builder_object = builder_object - self.session = None + def __init__(self, session): + self.session = session def __enter__(self): - self.session = self.builder_object.create() - self.session.sql('BEGIN').collect() + self.session.connection.cursor().execute('BEGIN') + print("BEGIN") return self.session def __exit__(self, exc_type, exc_val, exc_tb): if exc_type is not None: print("ERROR==>",exc_val) logging.error(exc_val) - self.session.sql('ROLLBACK').collect() + self.session.connection.cursor().execute('ROLLBACK') + print("ROLLBACK") return True else: - self.session.sql('COMMIT').collect() - self.session.close() \ No newline at end of file + self.session.connection.cursor().execute('COMMIT') + print("COMMIT") \ No newline at end of file