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.
close_connection()[source]

Do nothing

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.

drop_index(collection_name, name)[source]

Remove index from the database

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.

index_information(collection_name)[source]

Return dict of names and sorting order of indexes

initiate_connection()[source]

Do nothing

is_connected

Return true, always.

locked_database(write=True)[source]

Lock database file during wrapped operation call.

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.

remove(collection_name, query)[source]

Delete from a collection document[s] which match the query.

See also

AbstractDB.remove() for argument documentation.

write(collection_name, data, query=None)[source]

Write new information to a collection. Perform insert or update.

See also

AbstractDB.write() for argument documentation.

orion.core.io.database.pickleddb.find_unpickable_doc(dict_of_dict)[source]

Look for a dictionary that cannot be pickled.

orion.core.io.database.pickleddb.find_unpickable_field(doc)[source]

Look for a field in a dictionary that cannot be pickled