开发者

Best way to pull GAE Datastore data as a list

开发者 https://www.devze.com 2023-01-19 21:41 出处:网络
I\'m looking for the best way to pull info from the datastore into a list (with the intention of outputting to ReportLab to generate a pdf).Is there a way to do it besides looping through the output,

I'm looking for the best way to pull info from the datastore into a list (with the intention of outputting to ReportLab to generate a pdf). Is there a way to do it besides looping through the output, and creating a list fro开发者_如何学编程m it?


Per the source fetch() returns a list:

Returns: A list of db.Model instances...

The results of that query will look something like this:

[<models.YourModel object at 0x02641B30>, 
<models.YourModel object at 0x02641B70>]

Edit:
And then to get certain attributes of the model instances you'd do something like this:

values = [(model.name, model.type, model.source) 
          for model 
          in models_returned_from_query]

I don't know of any further shortcut for the above.

0

精彩评论

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