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', 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. 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
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.
-
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
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
AbstractDB.read_and_write()
for argument documentation.