对于Google Cloud DataStore上的现有实体,我想添加一个新属性作为斑点?

发布于 2025-02-02 15:30:25 字数 426 浏览 3 评论 0原文

对于Google Cloud DataStore上的现有实体,我想为该实体中的所有密钥添加一个新属性“ S11_DATA”。我单击键,然后单击新属性,并适当地命名,并保存和瞧。现在,它是所有密钥的属性列[设置为null]。但是我希望这个属性成为一个斑点(就像一些现有条目一样)。如果我单击现有条目之一,则“ Blob”是属性窗格的下拉菜单中的一个选项。

但这不是新属性的选择。我以为决议是确保关闭索引。但是,不,即使索引未选中,也没有出现斑点选项。

我很乐意通过python设置它是最好的方法,但是我也不能解决这个问题(我可以client.put()属性值,但找不到如何分配一个属性类型。

表示感谢,

编辑:这是显示“ blob”的下拉菜单=“ https://i.sstatic.net/l2nby.png” alt =“在此处输入图像说明”>

For existing entity on Google Cloud Datastore I would like to add a new property "s11_data" for all of the keys within that entity. I click on a key and click on New Property and name it appropriately, save, and voila. It is now a property column [set to null] for all of the keys. But I want this property to be a Blob (like some of the existing entries are already). If I click one of the existing entries, then "Blob" is an option in the drop-down menu of the property pane.

But it is not an option for the new property. I thought the resolution was to be sure to turn off indexing. But nope, even with Index unchecked the Blob option does not appear.

I'm happy to set it via Python is that is best way forward, but I can't work that out either (I can client.put() a property value but cannot find how to assign a property type.

Suggestions appreciated. Thanks,

Edit: here is the drop-down menu showing "Blob"enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贱贱哒 2025-02-09 15:30:25

如果您想通过Python在代码中进行此操作,那么如果您使用dataStore库(请参阅

  1. 但是,如果您使用NDB库,则 定义(请参阅
    s11_data = ndb.BlobProperty()
  1. 如果您使用云NDB库,也可以在模型定义中定义它(请参阅
    class YourModel(Model):
        s11_data = BlobProperty()
        
  1. ​请参阅 documentation (请参阅BlobValue字段)

If you wish to do it in code via Python, then I don't believe blob is a property if you're using the datastore library (see types). But you can get it as a property if you're using the ndb library

  1. If you're using the bundled ndb library, then you can set the property type in your model definition (see documentation for property types) e.g.
    s11_data = ndb.BlobProperty()
  1. If you're using cloud ndb library, you also define it in model definition (see documentation) e.g.
    class YourModel(Model):
        s11_data = BlobProperty()
        
  1. It looks like you can also specify a blob if you're directly making REST API calls. Refer to documentation (see blobValue field)
贩梦商人 2025-02-09 15:30:25

实际上比我想象的要容易。只需写一个字节类,Google自动将其设置为blob

json_data = {}
json_data["V"] = 0.123
json_data["Q"] = 4. 
a = codecs.encode(json.dumps(json_data).encode('utf-8'), encoding='zlib_codec')

with client.transaction():    
   task = client.get(key)    
   task["s11_data"] = a
   client.put(task)

“

Actually easier than I thought. Just write a bytes class and Google automatically sets it as a Blob

json_data = {}
json_data["V"] = 0.123
json_data["Q"] = 4. 
a = codecs.encode(json.dumps(json_data).encode('utf-8'), encoding='zlib_codec')

with client.transaction():    
   task = client.get(key)    
   task["s11_data"] = a
   client.put(task)

google snapshot

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文