Close the database. This may be needed if the storage instance used for this database needs to perform cleanup operations like closing file handles. To ensure this method is called, the TinyDB instance can be used as a context manager:: with Ti
(self)
| 212 | return self._storage |
| 213 | |
| 214 | def close(self) -> None: |
| 215 | """ |
| 216 | Close the database. |
| 217 | |
| 218 | This may be needed if the storage instance used for this database |
| 219 | needs to perform cleanup operations like closing file handles. |
| 220 | |
| 221 | To ensure this method is called, the TinyDB instance can be used as a |
| 222 | context manager:: |
| 223 | |
| 224 | with TinyDB('data.json') as db: |
| 225 | db.insert({'foo': 'bar'}) |
| 226 | |
| 227 | Upon leaving this context, the ``close`` method will be called. |
| 228 | """ |
| 229 | self._opened = False |
| 230 | self.storage.close() |
| 231 | |
| 232 | def __enter__(self): |
| 233 | """ |
no outgoing calls