Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/styllloz/public_html/qa-include/qa-base.php on line 1175

Warning: session_start(): Cannot start session when headers already sent in /home/styllloz/public_html/qa-include/app/users.php on line 162

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/users.php on line 1267

Warning: Cannot modify header information - headers already sent by (output started at /home/styllloz/public_html/qa-include/qa-base.php:1175) in /home/styllloz/public_html/qa-include/app/page.php on line 356
How to set your autoincrement primary key in AppEngine/Python? - code-flow.club | Q&A

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


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
12 views
There are, for example, class articles, copies of which are kept in Google release date storage. And I want to give a link to it:

[ a href="/article/{{ article.uid }}" ]

To make like this:

[ a href="/article/55" ]

Google has its UUID's, but they are a bit too scary for to be part of the url: ahBzb3ZpZXRncm9vdmVibG9ncg0LEgdBcnrpy2xlgagm.
by | 12 views

2 Answers

0 like 0 dislike
This has already been implemented. In addition to BigTable distributes keys and a numeric id. DB query by id:
\rModel.get_by_id()
To get the id of any entity — entity.key().id()
\r
It is quite suitable for a url, only to note that id will incremented for entities of any type in your application. One at all. Therefore, the numbers are big. For example, www.arhimir.ru/news/1126006 — done on GAE-Python.
by
0 like 0 dislike
probably have to use additional model:
\r
\r
class Sequence(db.Model): Key: db.StringProperty() #key, for example "ArticleId" Number: db.IntegerProperty(default=1) #the value itself 

and the meaning is — that in one transaction, first get the Number value and then update it by +1
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,179 users