开发者

Selecting values from a column with GQL in App Engine

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜