i have a query in sql that i want to convert in mongodb with python pymongo.
cursor=execute("select avg(id13)::numeric(10,2) from timestamppsql where timestamp1<='2011-01-01 00:05:00'")
This is the code i tested in mongodb:
cursor=mydb1.mongodbtime.aggregate({
'$group': {
"timestamp1":{ "$lte" : datetime.strptime("2011-01-01 00:05:00", "%Y-%m-%d %H:%M:%S") },
"avg_id13": {"$avg": "$id13"}
}
})
The output is this:
pipeline must be a list
How can i fix that?Any help would be appreciated.