Xela Yrag
0
Q:

pymongo update


  import pymongo

myclient = pymongo.MongoClient("mongodb://localhost:27017/")

  mydb = myclient["mydatabase"]
mycol = mydb["customers"]

  
myquery = { "address": "Valley 345" }
newvalues = { "$set": { 
  "address": "Canyon 123" } }

  
mycol.update_one(myquery, newvalues)

#print "customers" after the update:
for x in mycol.find():
  print(x) 
1

New to Communities?

Join the community