【问题标题】:How to access lowlevel API for storing data in Google App Engine for python如何访问用于在 Google App Engine for python 中存储数据的低级 API
【发布时间】:2010-10-04 16:22:54
【问题描述】:

在 python 版本中 Entity.java 的替代方案是什么? 我不想要任何数据模型。我希望我的实体没有预定义的结构。我只是希望它们像上面的 Entity.java 那样是键值对。

我可以用 Python 版本吗?

【问题讨论】:

    标签: python google-app-engine google-cloud-datastore


    【解决方案1】:

    “低级”API 位于 google.appengine.api.datastore 中。它没有公开文档,但模块本身具有相当完整的文档字符串。

    【讨论】:

      【解决方案2】:

      试试Expando 类。

      class MyModel(db.Expando)
         pass
      

      然后您可以通过简单地设置值来添加属性。它们也可以被移除。

      编辑: 我还应该提到dynamic properties 方法。它将返回为特定实体定义的属性列表。

      【讨论】:

      • 它似乎工作。但是 Expando 扩展了模型。有什么比我可以访问的模型更低的东西吗?
      • 如果您想要更低级别的内容,请参阅 Nick 的回复。查看 Tim 对此 (groups.google.com/group/google-appengine-python/browse_thread/…) 线程的回复。他举例说明了如何直接访问作为字典的数据存储对象。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多