diff --git a/src/core/trulens/core/database/sqlalchemy.py b/src/core/trulens/core/database/sqlalchemy.py index d0923a731..129ce5ebb 100644 --- a/src/core/trulens/core/database/sqlalchemy.py +++ b/src/core/trulens/core/database/sqlalchemy.py @@ -136,6 +136,18 @@ def __init__( def _reload_engine(self): if self.engine is None: + # Check if the dialect is snowflake and set isolation_level + if ( + "url" in self.engine_params + and "snowflake" in self.engine_params["url"] + ): + temp_engine = sa.create_engine(**self.engine_params) + if temp_engine.dialect.name == "snowflake": + self.engine_params.setdefault( + "isolation_level", "AUTOCOMMIT" + ) + # Dispose of the temporary engine + temp_engine.dispose() self.engine = sa.create_engine(**self.engine_params) self.session = sessionmaker(self.engine, **self.session_params)