etc
etc

Reputation: 565

Best way to pull GAE Datastore data as a list

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 from it?

Upvotes: 0

Views: 147

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169494

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.

Upvotes: 2

Related Questions