python - Google 应用引擎字符串到实体

标签 python google-app-engine

我想将任何字符串转换为我现有的实体。是否可以编写如下所示的 convertToEntity() 函数?

class Personel(db.Model):
  name=db.StringProperty()


class IsEntityExists(webapp.RequestHandler):
  def get(self):
    entity="Personal"
    Entity=entity.convertToEntity()
    Entity.all()

最佳答案

我想知道问题是否只是要求在模型类已被导入时以某种方式查找给定名称的模型类。您可以轻松地完成此操作(但前提是它已经导入!),如下所示:

cls = db.class_for_kind("Personel")
... cls.all() ...

NDB 中的等效项:

cls = ndb.Model._kind_map["Personel"]
... cls.query() ...

祝你好运!

PS。不,它不会进行拼写纠正。 :-)

关于python - Google 应用引擎字符串到实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11684246/

相关文章:

python - Pandas stack() 如果列具有特定值

python - 如何在 django 中编写带有过滤器和按条件排序的连接三个表的查询

python - 通过 Python 脚本抓取动态网站 : how to get the values?

python - Appengine Python 中的并发请求

javascript - 如何从 Javascript 调用经过 Firebase 身份验证的云端点?

java - 实体组、JPA 和每秒一次写入限制(应用程序引擎)

python - 为什么有两种语法将 np 数组传递给 cython 函数?

javascript - 如何获取文本区域的值?

java - ReSTLets GAE Android

python - Google App Engine/Requests 频繁出现 ChunkedEncodingError