MCPcopy
hub / github.com/msiemens/tinydb / close

Method close

tinydb/database.py:214–230  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 6

__exit__Method · 0.95
test_json_kwargsFunction · 0.95
test_json_readwriteFunction · 0.95
test_json_readFunction · 0.95
test_gcFunction · 0.95

Calls

no outgoing calls

Tested by 5

test_json_kwargsFunction · 0.76
test_json_readwriteFunction · 0.76
test_json_readFunction · 0.76
test_gcFunction · 0.76