python使用pymongo操作mongoDB(一)

python操作mongoDB的库pymongo

step1:根据python版本下载pymongo的镜像

https://pypi.org/project/pymongo/#modal-close

e.g:支持python2.7,下载pymongo-3.11.3-cp27-cp27mu-manylinux1_x86_64.whl

支持python3.6,下载pymongo-3.12.0-cp36-cp36m-manylinux1_x86_64.whl

step2:安装pymongo

step3:使用pymongo客户端登录mongoDB

操作数据库表:入参colletion是表名,one是数据字典或者字典列表

e.g collection='autotest', one={'name': 'test', 'time': cur_time, 'value': 'true'}

   退出mongoDB

  这里需要自行封装底层执行python命令行的exec_command()方法

 

posted @ 2021-08-26 19:19  阿昭  阅读(276)  评论(0编辑  收藏  举报