Choosing a data warehouse ID in Google App Engine?

I am trying to make a request that selects everything with id 6. The problem is that I cannot get it to work. Here's what the code looks like at the moment:

        query = db.GqlQuery("SELECT * FROM Users WHERE id = 6")
    result = query.get()
    for result in query:
        self.response.out.write(result.username)

There are no errors or anything but just displaying the username. Has anyone had this problem before or knew what I did wrong?

+3
source share
1 answer

If you use the value idassigned by the data store, there can only be one object with this identifier.

How about this:

idNum = 6
# handy function the datastore API provides...
user = Users.get_by_id(idNum)
self.response.out.write(user.username)
+4
source

Source: https://habr.com/ru/post/1778387/


All Articles