Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ndb云数据存储写入默认命名空间_Python_Google Cloud Platform_Google Cloud Datastore - Fatal编程技术网

Python ndb云数据存储写入默认命名空间

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

当尝试从python2升级到python3时,将数据写入不同的名称空间会出现问题

直到2020年5月14日,代码一直在编写以更正名称空间。之后,当尝试写入特定名称空间时,它会写入默认名称空间。如何解决这个问题

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版解决了这个问题。

这很有帮助,解决了这个问题。谢谢这很有帮助,解决了这个问题。谢谢