Skip to content

Commit

Permalink
perf(sqlalchemy): lazily construct the inspector object
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed May 22, 2023
1 parent 31ce741 commit 8db5624
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ibis/backends/base/sql/alchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _current_schema(self) -> str | None:

def do_connect(self, con: sa.engine.Engine) -> None:
self.con = con
self._inspector = sa.inspect(self.con)
self._inspector = None
self._schemas: dict[str, sch.Schema] = {}
self._temp_views: set[str] = set()

Expand All @@ -141,6 +141,8 @@ def list_databases(self, like=None):

@property
def inspector(self):
if self._inspector is None:
self._inspector = sa.inspect(self.con)
self._inspector.info_cache.clear()
return self._inspector

Expand Down

0 comments on commit 8db5624

Please sign in to comment.