Reference
srvdb.open
Open an existing database by path.
Open an existing database. The dimension, index and options are read from disk, so the path is all you pass.
srvdb.open(path: str) -> dbParameters
Section titled “Parameters”- path : str
Directory of a database made by
srvdb.create. Used exactly as given; nothing is created.
Returns
Section titled “Returns”The open database object (db). Use it in a with block to save and close it on exit; see the database object.
Raises
Section titled “Raises”-
FileNotFoundError No database exists at
path. -
ValueError A quantized database written by SrvDB 0.3 that has no recorded settings yet; see Upgrading.
-
BlockingIOError The database is already open, in this process or another (an
OSErrorsubclass). -
OSError The files cannot be read.
-
RuntimeError Stored data is damaged (checksum mismatch) or an internal fault occurred.
- It shadows the builtin
openonly inside thesrvdbnamespace; call it assrvdb.open. - Databases written by SrvDB 0.3 with full-precision vectors open as flat databases, as before.
- One database object holds a lock on the directory until
db.close(), the end of awithblock, or garbage collection; opening the same directory again before then raisesBlockingIOError. - Thread safety: the returned object is safe to share between threads. See Threads and processes.
Examples
Section titled “Examples”import srvdb
srvdb.create("./vectors", dimension=128, index="flat").close()with srvdb.open("./vectors") as db: print(db)# SrvDB(dimension=128, mode='flat', vectors=0)import srvdb
try: srvdb.open("./missing")except FileNotFoundError: print("no database yet")# no database yetSee also
Section titled “See also”srvdb.create: Create a new database with its index and options.- The database object: What
openreturns. db.save: Make every earlier write durable (crash-safe commit).
Was this page helpful? Tell us in Discussions.