Cloudant-Python 介绍
Cloudant-Python 是 CouchDB 和 Cloudant 实例的
Python 异步接口。封装了请求来处理头、JSON 序列化、流响应体等等功能的样板,例如:
import cloudant # connect to https://garbados.cloudant.com account = cloudant.Account('garbados', async=True) # and https://garbados.cloudant.com/allyourbase database = account.database('allyourbase') # create the database future = database.put() response = future.result() # throw an error if the response code indicates failure response.raise_for_status() print database.get().result().json() # { "db_name": "allyourbase", ... }
异步 HTTP 请求返回
Future 对象等待 HTTP 响应,可调用 Response 对象的 result() 方法来获取结果。如果你没有传递
async=True 则执行同步请求:
import cloudant # connect to http://localhost:5984 account = cloudant.Account() response = account.get() print response.json() # { "couchdb": "Welcome", ... }
获取 Cloudant-Python 的方法:
pip install cloudant
Cloudant-Python 官网
https://cloudant.com/blog/introducing-cloudant-python/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。