Guest User

Untitled

a guest
Dec 2nd, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. ### 基本用法
  2. ```python
  3.  
  4. from mongoengine import connect, DynamicDocument
  5.  
  6.  
  7. # connect as a default connection
  8. connect('project', host='192.168.20.19', port=8085, username='xxxx', password='xxxx')
  9.  
  10. # DynamicDocument: 动态文档,可直接使用不存在的字段
  11. class samplelist(DynamicDocument):
  12. pass
  13.  
  14. # query
  15. samplelist.objects(novoid='ZTD17036694')
  16.  
  17. # update
  18. # upsert=True 存在时更新,不存在时新建
  19. samplelist.objects(novoid='ZTD17036694').update(upsert=True, qccheck="Pass")
  20.  
  21. ```
Add Comment
Please, Sign In to add comment