learn of python driver for mongodb
来源:互联网 发布:类似双程的网络剧 编辑:程序博客网 时间:2024/06/05 21:02
一、安装:
python mongodb驱动: pymongo-2.1.1.tar.gz
python 主程序 : Python-2.7.2.tgz
1. 安装python
cd python/tar -xvf Python-2.7.2.tgzcd Python-2.7.2./configure --prefix=$HOME/mongodb/tools/python2.7make ; make install
2. 安装pymongo
cd python/tar -xvf pymongo-2.1.1.tar.gzcd pymongo-2.1.1python setup.py install
二、命令测试
1. 查询一行:
[aiobs8@aiobs8 python]$ pythonPython 2.7.2 (default, Sep 21 2012, 09:54:17) [GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> from pymongo import Connection >>> conn = Connection('localhost',27017);>>> db = conn.db>>> test = db.test>>> test.find_one();{u'_id': ObjectId('505bc6c0848e6c0a30d789ee'), u'id': 1, u'name': u'wangyf'}>>>
2. 插入一行数据:
>>> test.insert({'id':2,'name':'w2'})ObjectId('505d3fb207a15601a9000000')
3. 查询多行:
for str in test.find(): str{u'_id': ObjectId('505bc6c0848e6c0a30d789ee'), u'id': 1, u'name': u'wangyf'}{u'_id': ObjectId('505d3fb207a15601a9000000'), u'id': 2, u'name': u'w2'}
4. 查询用户名为w2的记录
>>> for str in test.find({'name':'w2'}):... str... {u'_id': ObjectId('505d3fb207a15601a9000000'), u'id': 2, u'name': u'w2'}>>>
5. 记录总数
>>> test.count()2>>>
- learn of python driver for mongodb
- MongoDB Driver For Java
- mongodb python driver--pymongo
- compile/install C++ driver for MongoDB fail
- run command from Java driver for MongoDB
- python for MongoDB部署
- mongodb learn
- Note of "Learn Python the HardWay"
- 【Python】Learn Python the hard way, ex32 for循环
- of driver
- Cannot create JDBC driver of class '' for connect URL 'null'
- Cannot create JDBC driver of class '' for connect URL 'null'
- Cannot create JDBC driver of class '' for connect URL 'null'
- Cannot create JDBC driver of class '' for connect URL 'null'
- cannot create jdbc driver of class '' for connect url 'null'
- Cannot create JDBC driver of class '' for connect URL 'null'
- Cannot create JDBC driver of class '' for connect URL 'null'
- Cannot create JDBC driver of class '' for connect URL 'null'
- 不止1.99亿!新12306.cn一期造价3.3亿元
- ashx页面中调用自定义的Profile
- 三种权限设计方案的归纳和比较
- web.xml配置文件
- 杂七杂八的小笔记
- learn of python driver for mongodb
- TCP心跳 | TCP keepAlive
- CMMI模型与SPICE标准对比分析
- hibernate+spring+struts
- Event对象(一)
- 关于delphi7 ActiveX的创建
- Java上传图片到服务器
- 成都JAVA培训,10月15日基础班传智播客
- Android设置GPS及获取经纬度坐标