MCPcopy Create free account
hub / github.com/ShivaBhattacharjee/KeyZen / __exit__

Method __exit__

data/python/08_context_managers.py:10–15  ·  view source on GitHub ↗
(self, exc_type, exc_val, exc_tb)

Source from the content-addressed store, hash-verified

8 return self
9
10 def __exit__(self, exc_type, exc_val, exc_tb):
11 print(f"Closing connection to '{self.db_name}'...")
12 self.connected = False
13 if exc_type:
14 print(f"An error occurred: {exc_val}")
15 return True
16
17 def query(self, sql):
18 if hasattr(self, 'connected') and self.connected:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected