开发者

Selecting values from a column with GQL in App Engine

开发者 https://www.devze.com 2023-02-25 16:54 出处:网络
I want to get the values from a particular column of a table. Whats the correct query for that ? Eg: Suppose we have a Crisis table which has a \"name\" column

I want to get the values from a particular column of a table. Whats the correct query for that ?

Eg: Suppose we have a Crisis table which has a "name" column

I want all the values in this column as a list

I tried "SELECT开发者_高级运维 name FROM Crisis" but it didnt work.

Edit:

Here is the exact code:

def get(self):
    c = db.GqlQuery('SELECT name FROM Crisis')

Error message:

Traceback (most recent call last):

...

c = db.GqlQuery('SELECT name FROM Crisis')

...

BadQueryError: Parse Error: Expected no additional symbols at symbol name


You can't select a single column from an entity. This is one of the most basic limitations of the App Engine datastore. You can retrieve the entire entity, or only its key.

def get(self):
  c = db.GqlQuery('SELECT * FROM Crisis')

  for entity in c:
    logging.info(entity.name)

Edit: To be more precise, there are no "columns" in App Engine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号