google云firestore api客户端库
google-cloud-firestore的Python项目详细描述
该API是灵活的、可伸缩的。
从firebase和google开发移动、web和服务器数据库
云平台。像firebase实时数据库一样,它将您的数据保存在
通过实时侦听器跨客户端应用程序同步并提供脱机支持
对于移动和网络,因此您可以构建响应式应用程序,而不必考虑
网络延迟或互联网连接云Firestore还提供无缝连接
与其他firebase和google云平台产品集成,
包括云功能。
快速启动
要使用此库,首先需要执行以下步骤:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Google Cloud Firestore API.
- Setup Authentication.
安装
使用pip在virtualenv中安装此库virtualenv是 创建独立的Python环境它解决的基本问题是 依赖项和版本,以及间接权限。
使用virtualenv,无需系统即可安装此库 安装权限,且不会与已安装的系统发生冲突 依赖关系。
支持的python版本
python=3.5
不推荐的python版本
python==2.7。Python2.7支持将于2020年1月1日取消。
Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-firestore
窗口
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-firestore
示例用法
fromgoogle.cloudimportfirestore# Add a new documentdb=firestore.Client()doc_ref=db.collection(u'users').document(u'alovelace')doc_ref.set({u'first':u'Ada',u'last':u'Lovelace',u'born':1815})# Then query for documentsusers_ref=db.collection(u'users')docs=users_ref.get()fordocindocs:print(u'{} => {}'.format(doc.id,doc.to_dict()))
下一步
- 阅读googlecloudfirestoreapi的Client Library Documentation 查看客户端上其他可用方法的API
- 阅读Product Documentation学习 有关产品的更多信息,请参见如何指导。