python 连接 mongodb
来源:互联网 发布:java se for mac10.11 编辑:程序博客网 时间:2024/04/30 06:17
首先下载pymongo并安装之:
https://pypi.python.org/pypi/pymongo/
代码奉上:
__author__ = 'bloodchilde'import pymongoclient = pymongo.MongoClient("localhost",27017)db = client.studycollection = db.personinsert_item = { "name":"zhengjinwei", "age":24, "email":"2538698032@qq.com", "country":"china"}ret = collection.insert(insert_item)if ret: print "insert success"ret = collection.remove({"name":"zhengjinwei"})if ret['ok'] and ret['n']: print "delete success"ret = collection.update({"name":"tom"},{"$set":{"name":"tom111"}})if ret['updatedExisting'] and ret['nModified']: print "update success"else: print "update failed"items = collection.find().sort("_id",pymongo.ASCENDING)for item in items: print item['name'],item['age'],item['email'],item['country']
0 0
- python 连接 mongodb
- python连接mongodb
- Python如何连接MongoDB
- python 连接 MongoDB
- python连接MongoDB
- python 连接 mongodb
- Python mongoDB 客户端连接
- python连接mongodb数据库
- Python 2.7 连接MongoDB
- python连接Mongodb
- Python-MongoDB连接搭建(二):Python连接MongoDB
- python连接mongodb环境配置
- python连接mongodb简明教程
- python连接mongodb并操作
- Python连接Mongodb和elasticsearch
- python与mongodb的连接
- python连接mongodb并操作
- python连接mongodb密码认证
- Java读书笔记三(字符串)
- 初始加密技术
- 星辉19年 豪礼巨献
- MySQL查询本周、上周、本月、上个月份数据的sql代码
- MFC webbrowser控件嵌入网页
- python 连接 mongodb
- 代理模式
- Servlet3.0学习总结(三)——基于Servlet3.0的文件上传
- 2015公司素质拓展
- Python字典 (dictionary)
- 警告: Scene is unreachable due to lack of entry points and does not have an identifier for runtime acc
- Xinetd介绍
- Android 手机影音 开发过程记录(三)
- verilog中的integer和reg的差别