Reference
db.close
Release the database and its lock without saving.
Release the database and its directory lock without saving.
db.close() -> NoneParameters
Section titled “Parameters”None.
Returns
Section titled “Returns”None.
Raises
Section titled “Raises”Nothing. Calling close() on a closed database does nothing.
- Writes since the last
save()are discarded. Callsave()first to keep them, or use awithblock, which saves on a clean exit. - After
close(), every other method raisesValueError(“this Database is closed”), and the directory can be opened again or deleted. - Without
close(), the lock is released when the object is garbage-collected. - Thread safety:
close()waits for running calls to finish.
Examples
Section titled “Examples”import srvdb
db = srvdb.create("./vectors", dimension=128)db.add(["a"], [[1.0] + [0.0] * 127], ["{}"])db.save()db.close()print(db)# SrvDB(closed)print(srvdb.open("./vectors").count())# 1See also
Section titled “See also”db.save: Make every earlier write durable (crash-safe commit).- The database object: The context manager.
Was this page helpful? Tell us in Discussions.