How to set your autoincrement primary key in AppEngine / Python?

Asked bysara veldhuizen stealy

There is, say, a class of an article, copies of which are stored in Google’s date of storage. And I want to give her a link:

[a href = & quot; / article / {{article.uid}} & quot; ]

To get this type:

[a href = & quot; / article / 55 & quot; ]

Google has its own UUIDs, but it hurts to be part of the URL: ahBzb3ZpZXRncm9vdmVibG9ncg0LEgdBcnRpY2xlGAgM.


betsy vega
This has already been implemented. In addition to keys, BigTable distributes numeric id. Query DB by id:
To get the id of any entity - entity.key (). Id ()

It is quite suitable for URLs, just keep in mind that id is incremented for entities of any type in your application. One for all. Therefore, the numbers come out big. For example, - made in GAE-Python.
Thank you! A very suitable way for me.

In, uid articles are probably also “incremented” by this technique :) - queenbusick
I really need the SQL-like option ... especially because of migration from SQL to GAE DB - stacy davidowitz
scott lerch
will most likely have to use an additional model:

class Sequence(db.Model):
    Key: db.StringProperty() #ключ, например "ArticleId"
    Number: db.IntegerProperty(default=1) #само значение

and the point is that in one transaction, we first get the value of Number, and immediately update it with +1
Is there a master password in Google Chrome? :: How reliable is DRDB? :: Can I change the error page to my own in Google Chrome? :: How not to work overtime? :: Prompt the best program for working with PostgreSQL under Mac OS
Leave Repply forHow to set your autoincrement primary key in AppEngine / Python?
Useful Links