如何使用pymongo更新和删除mongo中的记录

时间:2018-02-17 11:02:21

标签: python mongodb python-2.7 pymongo

我正在尝试使用pymongo进行插入/更新/删除。我的插入工作,但更新和删除不成功

int UserAccountType =getIntent.getIntExtra("accountType");

删除

def update(self,test1):
print "hi"
    client=MongoClient('localhost',27017)
    db=client.test  
    collection=db.test1
    # result = collection.test1.update_one({'col1': 1}, {'$set': {'col2': 'name'}})
    result = collection.test1.update_one(
        {"col4": 'fddf'},
        {
            "$set":
            {
                "col1":'12.0'                    
            }
        }, upsert=False
        )

此外,它不会给出任何错误。但是当我检查mongo表时,它不会改变。

任何更新都非常适合。

0 个答案:

没有答案
相关问题