cowbird.database.mongodb

Attributes

MongoDB

MongodbStores

AnyMongodbStore

AnyMongodbStoreType

Classes

MongoDatabase

Return the unique identifier of db type matching settings.

Functions

get_mongodb_connection(→ pymongo.database.Database)

Obtains the basic database connection from settings.

get_mongodb_engine(→ pymongo.database.Database)

Obtains the database with configuration ready for usage.

Module Contents

cowbird.database.mongodb.MongoDB: pymongo.database.Database | None = None[source]
cowbird.database.mongodb.MongodbStores[source]
cowbird.database.mongodb.AnyMongodbStore[source]
cowbird.database.mongodb.AnyMongodbStoreType[source]
class cowbird.database.mongodb.MongoDatabase(container: cowbird.typedefs.AnySettingsContainer)[source]

Bases: cowbird.database.base.DatabaseInterface

Return the unique identifier of db type matching settings.

Initialize the mongo database from various type of container.

_database: pymongo.database.Database = None[source]
_settings: cowbird.typedefs.SettingsType = None[source]
_stores: Dict[str, AnyMongodbStore] = None[source]
type = 'mongodb'[source]
reset_store(store_type: AnyMongodbStoreType) AnyMongodbStore | None[source]
get_store(store_type: str | Type[cowbird.database.stores.StoreInterface] | AnyMongodbStoreType, *store_args: Any, **store_kwargs: Any) AnyMongodbStore[source]

Retrieve a store from the database.

Parameters:
  • store_type – type of the store to retrieve/create.

  • store_args – additional arguments to pass down to the store.

  • store_kwargs – additional keyword arguments to pass down to the store.

get_session() Any[source]
get_information() cowbird.typedefs.JSON[source]
Returns:

{‘version’: version, ‘type’: db_type}

is_ready() bool[source]
cowbird.database.mongodb.get_mongodb_connection(container: cowbird.typedefs.AnySettingsContainer) pymongo.database.Database[source]

Obtains the basic database connection from settings.

cowbird.database.mongodb.get_mongodb_engine(container: cowbird.typedefs.AnySettingsContainer) pymongo.database.Database[source]

Obtains the database with configuration ready for usage.