PickledDB database¶
Pickled Database¶
Implement permanent version of orion.core.io.database.ephemeraldb.EphemeralDB
.
-
class
orion.core.io.database.pickleddb.
PickledDB
(host='', timeout=60, *args, **kwargs)[source]¶ Pickled EphemeralDB to support permanancy and concurrency
This is a very simple and inefficient implementation of a permanent database on disk for Oríon. The data is loaded from disk for every operation, and every operation is protected with a filelock.
Parameters: - host: str
File path to save pickled ephemeraldb. Default is {user data dir}/orion/orion_db.pkl ex: $HOME/.local/share/orion/orion_db.pkl
- timeout: int
Maximum number of seconds to wait for the lock before raising DatabaseTimeout. Default is 60.
Attributes: - instance
is_connected
Return true, always.
Methods
close_connection
()Do nothing count
(collection_name[, query])Count the number of documents in a collection which match the query. drop_index
(collection_name, name)Remove index from the database ensure_index
(collection_name, keys[, unique])Create given indexes if they do not already exist in database. get_defaults
()Get database arguments needed to create a database instance. index_information
(collection_name)Return dict of names and sorting order of indexes initiate_connection
()Do nothing locked_database
([write])Lock database file during wrapped operation call. read
(collection_name[, query, selection])Read a collection and return a value according to the query. read_and_write
(collection_name, query, data)Read a collection’s document and update the found document. remove
(collection_name, query)Delete from a collection document[s] which match the query. write
(collection_name, data[, query])Write new information to a collection. -
count
(collection_name, query=None)[source]¶ Count the number of documents in a collection which match the query.
See also
orion.core.io.database.AbstractDB.count()
for argument documentation.
-
ensure_index
(collection_name, keys, unique=False)[source]¶ Create given indexes if they do not already exist in database.
Indexes are only created if unique is True.
-
classmethod
get_defaults
()[source]¶ Get database arguments needed to create a database instance.
See also
orion.core.io.database.AbstractDB.get_defaults()
for argument documentation.
-
is_connected
¶ Return true, always.
-
read
(collection_name, query=None, selection=None)[source]¶ Read a collection and return a value according to the query.
See also
orion.core.io.database.AbstractDB.read()
for argument documentation.
-
read_and_write
(collection_name, query, data, selection=None)[source]¶ Read a collection’s document and update the found document.
Returns the updated document, or None if nothing found.
See also
orion.core.io.database.AbstractDB.read_and_write()
for argument documentation.
-
remove
(collection_name, query)[source]¶ Delete from a collection document[s] which match the query.
See also
orion.core.io.database.AbstractDB.remove()
for argument documentation.
-
write
(collection_name, data, query=None)[source]¶ Write new information to a collection. Perform insert or update.
See also
orion.core.io.database.AbstractDB.write()
for argument documentation.