EphemeralDB Database¶
orion.core.io.database.ephemeraldb
– Non permanent database¶
-
class
orion.core.io.database.ephemeraldb.
EphemeralCollection
[source]¶ Non permanent collection
This collection is meant for debugging purposes within the EphemeralDB.
See also
orion.core.io.database.ephemeraldb.EphemeralDB
for database object.Methods
count
([query])Count the number of documents in a collection which match the query. create_index
(keys[, unique])Create given indexes if they do not already exist for this collection. delete_many
([query])Delete from a collection document[s] which match the query. drop
()Drop the collection, removing all documents and indexes. drop_index
(name)Remove index from the database find
([query, selection])Find documents in the collection and return a value according to the query. index_information
()Return dict of names and sorting order of indexes insert_many
(documents)Add new documents in the collection. update_many
(query, update)Update documents matching the query -
count
(query=None)[source]¶ Count the number of documents in a collection which match the query.
See also
AbstractDB.count()
for argument documentation.
-
create_index
(keys, unique=False)[source]¶ Create given indexes if they do not already exist for this collection.
Indexes are only created if unique is True.
-
delete_many
(query=None)[source]¶ Delete from a collection document[s] which match the query.
See also
AbstractDB.remove()
for argument documentation.
-
drop_index
(name)[source]¶ Remove index from the database
EphemeralCollection may only contain unique indexes.
-
find
(query=None, selection=None)[source]¶ Find documents in the collection and return a value according to the query.
See also
AbstractDB.read()
for argument documentation.
-
index_information
()[source]¶ Return dict of names and sorting order of indexes
EphemeralCollection may only contain unique indexes.
-
-
class
orion.core.io.database.ephemeraldb.
EphemeralDB
(host='localhost', name=None, port=None, username=None, password=None, **kwargs)[source]¶ Non permanent database
This database is meant for debugging purposes. It only lives through one execution and all information saved during it is lost when the process is terminated.
See also
orion.core.io.database.AbstractDB
for more on attributes.Attributes: - instance
is_connected
Return true, always.
Methods
close_connection
()Remove the dictionary 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
()Create the dictionary which serve as an ephemeral database 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.
-
class
orion.core.io.database.ephemeraldb.
EphemeralDocument
(data)[source]¶ Non permanent document
This document is meant for debugging purposes within the EphemeralDB.
See also
orion.core.io.database.ephemeraldb.EphemeralDB
for database object.Methods
match
([query])Test if the document corresponds to a given query match_key
(key, value)Test if a data corresponding to the given key is in agreement with the given value based on the operator defined within the key. select
(keys)Only select or only drop the specified keys to_dict
()Convert the ephemeral document to a python dictionary update
(data)Update the values of the document. -
match_key
(key, value)[source]¶ Test if a data corresponding to the given key is in agreement with the given value based on the operator defined within the key.
Default operator is equal when no operator is defined. Other operators could be $ne, $in, $gte, $gt or $lte. They are defined in the last section of the key. For example: abc.def.$in or abc.def.$gte.
-
select
(keys)[source]¶ Only select or only drop the specified keys
For a pair (key, value) in the dictionnary, value=0 means the key will not be included while value=1 means it will.
All specified keys should be 0 or 1. They cannot have different values with the exception of _id which can be specified to 0 while the others are at 1. The _id field is always returned unless specified with 0.
Parameters: - keys: dict
Pairs of keys and 0 or 1s. When a key is associated with 1, it is kept in the selection, otherwise it is dropped.
-