[Python] python mongoening time series collection support

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    I was looking for a solution for storage and retrieval of time series data.

    As I have mongodb set up already in my project, I searched for a solution with mongodb and mongoengine (instead of pymongo).

    So I wonder if there a similar solution to this for mongoengine or if there ain't one, how-to develop it.

    {
    "_id" : ObjectId("60c0d44894c10494260da31e"),
    "source" : {sensorId: 123, region: "americas"},
    "airPressure" : 99 ,
    "windSpeed" : 22,
    "temp" : { "degreesF": 39,
    "degreesC": 3.8
    },
    "ts" : ISODate("2021-05-20T10:24:51.303Z")
    }

    db.createCollection("weather", {
    timeseries: {
    timeField: "ts",
    metaField: "source",
    granularity: "minutes"
    },
    expireAfterSeconds: 9000
    });


    Sample code is taken from MongoDB's New Time Series Collections in which the solution by pymongo is described but I wanna do it with mongoengine. Is that possible?

    Continue reading...

Compartilhe esta Página