Close the database connection.
(self)
| 13 | self._create_history_table() |
| 14 | |
| 15 | def close(self): |
| 16 | """Close the database connection.""" |
| 17 | if self._closed: |
| 18 | return |
| 19 | with self._lock: |
| 20 | if self.connection: |
| 21 | try: |
| 22 | self.connection.close() |
| 23 | except Exception: |
| 24 | pass |
| 25 | self.connection = None |
| 26 | self._closed = True |
| 27 | |
| 28 | def __del__(self): |
| 29 | """Destructor to ensure connection is closed.""" |