我正在将上次保存的数据检索到文本字段,以便用户可以继续他们之前所做的工作,此命令在 mongo 控制台中运行良好,在 PyCharm 中我无法找出编写 find() 查询的正确方法
我尝试按照此处的建议将过滤器参数存储在 2 个单独的变量中pymongo error: filter must be an instance of dict, bson.son.SON, or other type that inherits from collections.Mapping
Database.initialize()
db_data = Database.find(collection = 'notes_temp',
query = ({"priority" : self.priority}, {'td': 1, '_id':0}))
for task in db_data:
self.t.insert('insert linestart', task)
数据库模块
class Database:
URI = "mongodb://127.0.0.1:27017"
DATABASE = None
@staticmethod
def initialize():
client = pymongo.MongoClient(Database.URI)
Database.DATABASE = client['notes']
@staticmethod
def find(collection, query):
return Database.DATABASE[collection].find(query)