Pymongo controls the method of adding numeric fields of mongodb

From , 5 Years ago, written in Python, viewed 212 times.
URL https://pastebin.vip/view/93ac0c50
  1. import pymongo #导入pymongo 模块
  2. conn = pymongo.Connection() #连接本地mongodb数据库
  3. db=conn.database  #database为数据库名称
  4. collection = db.article #article为collection名称,相当于mysql里的表名
  5. collection.update({'_id':ObjectId(id),'$inc':{'hit':1}})  # 为hit字段增加1
  6. #//python/8479

Reply to "Pymongo controls the method of adding numeric fields of mongodb"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website