【问题标题】:fetch_async and get_result ndb equivalent in FirestoreFirestore 中的 fetch_async 和 get_result ndb 等效项
【发布时间】:2021-06-16 14:41:30
【问题描述】:

我们正在尝试在 Google 标准环境应用引擎中将应用程序从 Python 2.7 迁移到 Python 3.6。 Python 2.7 有 NDB 数据存储,python 3.6 环境有 firestore。我们正在将数据库从 NDB 更改为 Firestore。

我们在 NDB 数据存储中有一个相互独立的查询列表。它们使用 fetch_async 触发,然后我们使用 get_result 收集查询结果。

 mutually_exclusive_query1.fetch_async()
 mutually_exclusive_query2.fetch_async()
 mutually_exclusive_query3.fetch_async()
 mutually_exclusive_query4.fetch_async()
 mutually_exclusive_query5.fetch_async()

 mutually_exclusive_query1.get_result()
 mutually_exclusive_query2.get_result()
 mutually_exclusive_query3.get_result()
 mutually_exclusive_query4.get_result()
 mutually_exclusive_query5.get_result()

目标是确保每个查询不会一个接一个地排序。响应时间取决于执行时间最长的查询。

Firestore (python 3.6) 中是否有类似的功能?

【问题讨论】:

    标签: python-3.x google-cloud-firestore


    【解决方案1】:

    您仍然可以将 NDB 与 python 3 (https://github.com/googleapis/python-ndb) 一起使用。您可以使用 Cloud NDB 从非 App Engine 环境或直接使用 Datastore API (https://googleapis.dev/python/datastore/latest/index.html) 访问现有数据库。

    【讨论】:

    • 我们不想使用 NDB。我们正在迁移到 Firestore。
    猜你喜欢
    • 1970-01-01
    • 2019-07-23
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 2020-07-25
    • 2016-03-02
    • 2011-06-04
    • 1970-01-01
    相关资源
    最近更新 更多