Python ndb云数据存储写入默认命名空间
当尝试从python2升级到python3时,将数据写入不同的名称空间会出现问题 直到2020年5月14日,代码一直在编写以更正名称空间。之后,当尝试写入特定名称空间时,它会写入默认名称空间。如何解决这个问题Python ndb云数据存储写入默认命名空间,python,google-cloud-platform,google-cloud-datastore,Python,Google Cloud Platform,Google Cloud Datastore,当尝试从python2升级到python3时,将数据写入不同的名称空间会出现问题 直到2020年5月14日,代码一直在编写以更正名称空间。之后,当尝试写入特定名称空间时,它会写入默认名称空间。如何解决这个问题 from google.cloud import ndb client = ndb.Client() class ActiveTokens(ndb.Model): _memcache_timeout = 60 namespace = user_namespace
from google.cloud import ndb
client = ndb.Client()
class ActiveTokens(ndb.Model):
_memcache_timeout = 60
namespace = user_namespace
username = ndb.StringProperty(required=True, indexed=True)
token = ndb.StringProperty(required=True, indexed=True)
expiry = ndb.IntegerProperty(required=True)
otp = ndb.IntegerProperty(indexed=True)
created = ndb.DateTimeProperty(auto_now_add=True, required=True, indexed=True)
edited = ndb.DateTimeProperty(auto_now=True, required=True)
@classmethod
def store(cls, username, token, expiry, otp):
with client.context():
obj = ActiveTokens(username=username,
token=token,
expiry=expiry,
otp=otp,
namespace='user'
)
return obj.put().id()
今天早上在将实例部署到云中时,我开始遇到这个问题。这不是在我的开发环境中发生的。尽管在模型中设置了[default]名称空间,但我的实体仍保存在该名称空间下。我通过将google cloud ndb从1.2.1版降级到1.1.2版解决了这个问题。今天早上在将实例部署到云中时,我开始遇到这个问题。这不是在我的开发环境中发生的。尽管在模型中设置了[default]名称空间,但我的实体仍保存在该名称空间下。我通过将google cloud ndb从1.2.1版降级到1.1.2版解决了这个问题。这很有帮助,解决了这个问题。谢谢这很有帮助,解决了这个问题。谢谢