Tom
Tom

Reputation:

How to retrieve google appengine entities using their numerical id?

Is it possible to retrieve an entity from google appengine using their numerical IDs and if so how? I tried using:

key = Key.from_path("ModelName", numericalId) m = ModelName.get(key)

but the key generated wasnt correct.

Upvotes: 3

Views: 1500

Answers (4)

Sopoforic
Sopoforic

Reputation: 130

Other answers refer to the old DB API. New applications will by default use the NDB datastore, which has a slightly different API. You can still do Model.get_by_id(id, parent) to retrieve an entity by id, but the NDB also supports options to specify the app and namespace. See the documentation for details.

Upvotes: 0

Tom
Tom

Reputation:

Turns out I needed to do

key = Key.from_path( Application_ModelName, numeric_id )

wasn't clear till i looked at the dict() of an entity

Upvotes: 0

Rik
Rik

Reputation: 29243

Getting an Entity Using a Key

Upvotes: 0

Related Questions