If you want to get something by it's ID, you'd probably want to use get_by_id(): http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_id
<http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_id>where you could give it a single ID.. or a list of IDs.. and then delete the result. On Wed, Aug 18, 2010 at 8:33 AM, TZ <[email protected]> wrote: > Hi. > I want to recode my python webapplication script because it should run > on the Google App Engine. > Before I used SQL but now I must rewrite my database queries in GQL/ > Datastore by Google. > > I have problems to delete database entries. I want delete entries by > ID but it doesn't work. > > My db class: > > <code> > class board_topic_entry(db.Model): > title = db.StringProperty(required=True) > name = db.StringProperty(required=True) > message = db.TextProperty() > </code> > > The column "ID" is generated and filled with consecutive numbers > automatically. True? > > When I want delete a explicit database entry, I use this query: > > (for example) > > <code> > #... > q = db.GqlQuery("SELECT __key__ FROM board_topic_entry WHERE > ID=20") > results = q.fetch(10) > db.delete(results) > return 'deleted' > </code> > > It doesn't work! (But I get no error messages) When I do an operation > with an other database column such as: > > <code> > #... > q = db.GqlQuery("SELECT __key__ FROM board_topic_entry WHERE > title='test123'") > results = q.fetch(10) > db.delete(results) > return 'deleted' > </code> > > IT WORKS! > > Why? > How can I say: "Please delete the entry with the ID "X" ? > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
