Google APP Engine(GAE) ID auto increment

Google App Engine project , datastore use auto increment id, ref this link: http://stackoverflow.com/questions/2529620/google-app-engine-auto-increment

USE:

class Loger(db.Model):
name = db.StringProperty()
url = db.StringProperty()
log = db.StringProperty()
date_add = db.DateTimeProperty(auto_now_add=True)

delete data:

log = Loger.get_by_id(id)
log.delete()

Loger: Entry

results = q.fetch(row_num)
for r in results:
ls.append((r.name, r.url, r.log, (r.date_add + datetime.timedelta(hours=+8)).strftime(‘%Y-%m-%d %H:%M:%S’), r.key().id()))

PUT data:

loger = Loger()
loger.name = name
loger.url = url
loger.log = log
loger.put()

 更新:

自动的ID号,并不是按插入顺序增长的,看起来是无序的?

 

 

此条目发表在Program分类目录,贴了, , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>