PickledDB database¶
orion.core.io.database.pickleddb – Pickled Database¶
-
class
orion.core.io.database.pickleddb.PickledDB(host='/home/docs/.local/share/orion.core/orion/orion_db.pkl', *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
Attributes: - instance
is_connectedReturn true, always.
Methods
close_connection(self)Do nothing count(self, collection_name[, query])Count the number of documents in a collection which match the query. drop_index(self, collection_name, name)Remove index from the database ensure_index(self, collection_name, keys[, …])Create given indexes if they do not already exist in database. index_information(self, collection_name)Return dict of names and sorting order of indexes initiate_connection(self)Do nothing locked_database(self[, write])Lock database file during wrapped operation call. read(self, collection_name[, query, selection])Read a collection and return a value according to the query. read_and_write(self, collection_name, query, …)Read a collection’s document and update the found document. remove(self, collection_name, query)Delete from a collection document[s] which match the query. write(self, collection_name, data[, query])Write new information to a collection. -
count(self, collection_name, query=None)[source]¶ Count the number of documents in a collection which match the query.
See also
AbstractDB.count()for argument documentation.
-
ensure_index(self, 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.
-
is_connected¶ Return true, always.
-
read(self, collection_name, query=None, selection=None)[source]¶ Read a collection and return a value according to the query.
See also
AbstractDB.read()for argument documentation.
-
read_and_write(self, 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
AbstractDB.read_and_write()for argument documentation.