EphemeralDB Database

Non permanent database

Implement non permanent version of orion.core.io.database.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

orion.core.io.database.Database.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

orion.core.io.database.Database.remove() for argument documentation.

drop()[source]

Drop the collection, removing all documents and indexes.

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

orion.core.io.database.Database.read() for argument documentation.

index_information()[source]

Return dict of names and sorting order of indexes

EphemeralCollection may only contain unique indexes.

insert_many(documents)[source]

Add new documents in the collection.

If the documents do not have a keys _id, they are assigned by default the max id + 1.

Raises
DuplicateKeyError

If the document contains unique indexes which are already present in the database.

update_many(query, update)[source]

Update documents matching the query

Raises
DuplicateKeyError

If the update creates a duplication of unique indexes in the database.

class orion.core.io.database.ephemeraldb.EphemeralDB(host=None, 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.Database for more on attributes.

Attributes
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.

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()

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.

close_connection()[source]

Remove the dictionary

count(collection_name, query=None)[source]

Count the number of documents in a collection which match the query.

See also

orion.core.io.database.Database.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.

classmethod get_defaults()[source]

Get database arguments needed to create a database instance.

See also

orion.core.io.database.Database.get_defaults() for argument documentation.

index_information(collection_name)[source]

Return dict of names and sorting order of indexes

initiate_connection()[source]

Create the dictionary which serve as an ephemeral database

property 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.Database.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.Database.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.Database.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.Database.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(query=None)[source]

Test if the document corresponds to a given query

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 dictionary, 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.

to_dict()[source]

Convert the ephemeral document to a python dictionary

update(data)[source]

Update the values of the document.

Parameters
data: dict

Dictionary of data to update the document. If $set is in the data, the corresponding data[$set] will be used instead.