【发布时间】:2021-03-02 17:07:55
【问题描述】:
我正在使用 pymongo 在 python 中工作。 我在 psql 中有一个如下所示的查询:
cursor.execute("select id13 from nc_durhamallwithorder where date2 >='2010-01-01' and date2<='2011-01-01'"),
现在我想将该查询转换为 mongodb 类型。 我做了这样的事情
cursor=mycol1.find({"$and": [ { "date2": { "$gte": "2010-01-01" } }, { "date2": { "$lte":"2011-01-01" } } ] } )
这很好,但我只想选择 id13
我是这样想的:
cursor=mycol1.find({"id13":1},{"$and": [ { "date2": { "$gte": "2010-01-01" } }, { "date2": { "$lte":"2011-01-01" } } ] } )
但它不起作用。有人可以帮助我吗?
【问题讨论】:
标签: python sql mongodb postgresql pymongo