基于tornado IOLoop构建的异步mongodb访问库。
项目描述
asyncmongo
==========
AsyncMongo是一个用于访问mongo的异步库
它是基于tornado ioloop构建的。
[](https://travis-ci.org/bitly/asyncmongo)
安装
------------
安装:`pip install asyncmongo`
用法
-----
asyncmongo语法力求与[pymongo](http://api.mongodb.org/python/current/api/pymongo/collection.html)相似。
import asyncmongo
import tornado.web
class Handler(tornado.web.RequestHandler)
@property
def db(self)
if not hasattr(self, '_db')
self._db = asyncmongo.Client(pool_id='mydb', host='127.0.0.1', port=27017, maxcached=10, maxconnections=50, dbname='test')
return self._db
@tornado.web.asynchronous
def get(self)
self.db.users.find({'username': self.current_user}, limit=1, callback=self._on_response)
# 或
# conn = self.db.connection(collectionname="...", dbname="...")
# conn.find(..., callback=self._on_response)
def _on_response(self, response, error)
if error
raise tornado.web.HTTPError(500)
self.render('template', full_name=response['full_name'])
关于
-----
一些功能目前尚未实现
* 直接与索引交互,删除集合
* 分批检索结果,而不是一次性检索
(asyncmongo 的特性意味着无论您检索多少结果,都不会有调用阻塞)
* 可尾游标 #15
需求
------------
以下两个 Python 库是必需的
* [pymongo](http://github.com/mongodb/mongo-python-driver) 版本 1.9+ 用于 bson 库
* [tornado](http://github.com/facebook/tornado)
问题
------
请通过 [github issues](https://github.com/bitly/asyncmongo/issues) 报告任何问题
==========
AsyncMongo是一个用于访问mongo的异步库
它是基于tornado ioloop构建的。
[](https://travis-ci.org/bitly/asyncmongo)
安装
------------
安装:`pip install asyncmongo`
用法
-----
asyncmongo语法力求与[pymongo](http://api.mongodb.org/python/current/api/pymongo/collection.html)相似。
import asyncmongo
import tornado.web
class Handler(tornado.web.RequestHandler)
@property
def db(self)
if not hasattr(self, '_db')
self._db = asyncmongo.Client(pool_id='mydb', host='127.0.0.1', port=27017, maxcached=10, maxconnections=50, dbname='test')
return self._db
@tornado.web.asynchronous
def get(self)
self.db.users.find({'username': self.current_user}, limit=1, callback=self._on_response)
# 或
# conn = self.db.connection(collectionname="...", dbname="...")
# conn.find(..., callback=self._on_response)
def _on_response(self, response, error)
if error
raise tornado.web.HTTPError(500)
self.render('template', full_name=response['full_name'])
关于
-----
一些功能目前尚未实现
* 直接与索引交互,删除集合
* 分批检索结果,而不是一次性检索
(asyncmongo 的特性意味着无论您检索多少结果,都不会有调用阻塞)
* 可尾游标 #15
需求
------------
以下两个 Python 库是必需的
* [pymongo](http://github.com/mongodb/mongo-python-driver) 版本 1.9+ 用于 bson 库
* [tornado](http://github.com/facebook/tornado)
问题
------
请通过 [github issues](https://github.com/bitly/asyncmongo/issues) 报告任何问题
项目详情
关闭
asyncmongo-1.3.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8d69a76bbf0491215eb241b48dad52f3e873859ddd9bcb275ac5ed4d90bbd1c0 |
|
MD5 | 88af0421a74c46ff4dcddcfa4957da06 |
|
BLAKE2b-256 | e57d924572ce809dbfc9ac378f1e42ccf4261533b4b2e59bf664913c490dbc7e |