databay.outlets.mongo_outlet¶
Warning
MongoOutlet
requires PyMongo to function. Please install required dependencies using:
pip install "databay[MongoOutlet]"
Contents:
Raised when requested collection does not exist in the database. |
|
Ensure the MongoDB connection is established before running the function. |
|
Outlet for pushing data into a MongoDB instance. Pushes are executed synchronously. |
-
exception
databay.outlets.mongo_outlet.
MongoCollectionNotFound
[source]¶ databay.outlets.mongo_outlet.MongoCollectionNotFound
Raised when requested collection does not exist in the database.
Initialize self. See help(type(self)) for accurate signature.
Bases:
Exception
-
databay.outlets.mongo_outlet.
ensure_connection
(fn)[source]¶ Ensure the MongoDB connection is established before running the function.
- Parameters
fn (
Callable
) – Function to decorate
-
class
databay.outlets.mongo_outlet.
MongoOutlet
(database_name: str = 'databay', collection: str = 'default_collection', host: str = None, port: str = None, *args, **kwargs)[source]¶ databay.outlets.mongo_outlet.MongoOutlet
Outlet for pushing data into a MongoDB instance. Pushes are executed synchronously.
- Parameters
database_name (str) – Name of the MongoDB database to write to.
Default:'databay'
collection (str) – Global name of the collection to write to. This can be overwritten by records’ metadata.MONGODB_COLLECTION parameter.
Default:'default_collection'
host (str) – Address of MongoDB host.
Default:None
(PyMongo defaults to'localhost'
)port (int) – Port of the MongoDB host.
Default:None
(PyMongo defaults to27017
)
Bases:
databay.outlet.Outlet
-
push
(self, records: [Record], update)[source]¶ -
Write records into the database. Writes are executed synchronously.
- Parameters
records (list[
Record
]) – List of records generated by inlets. Each top-level element of this array corresponds to one inlet that successfully returned data. Note that inlets could return arrays too, making this a nested array.update (
Update
) – Update object representing the particular Link transfer.