Close the database connection and dispose of the engine. This ensures proper cleanup of resources.
(self)
| 470 | Base.metadata.create_all(self.engine) |
| 471 | |
| 472 | def close(self): |
| 473 | """ |
| 474 | Close the database connection and dispose of the engine. |
| 475 | This ensures proper cleanup of resources. |
| 476 | """ |
| 477 | # Remove thread-local sessions from scoped_session registry |
| 478 | if hasattr(self, 'Session'): |
| 479 | self.Session.remove() |
| 480 | |
| 481 | # Dispose of the connection pool |
| 482 | if hasattr(self, 'engine'): |
| 483 | self.engine.dispose() |