遍历gridfs数据表

来源:互联网 发布:linux find mtime 0 编辑:程序博客网 时间:2024/05/21 17:42
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pymongo
from pymongo import Connection
import gridfs

strConn = 'mongodb://xxxxx:xxxxx@xxxxx/test?slaveOk=true'
dbname = 'test'
__connection = Connection( strConn )
db = __connection[dbname]

cursor = db.picture.files.find()

while cursor.alive:
    try:
        resultDict = cursor.next()
        print resultDict
    except StopIteration, e:
        isAlive = False
        break
    except Exception, e:
        print str(e)
0 0
原创粉丝点击