简体   繁体   English

引导Google App Engine本地数据库的数据

[英]Bootstrapping data for Google App Engine local database

Is there a way to programmatically add entities to the GAE database? 有没有办法以编程方式将实体添加到GAE数据库? I'm wondering if there is something that parallels Django's fixtures . 我想知道是否有与Django的灯具相似的东西。 Everything that I have found so far indicates you can only do it by a custom url handler which seems inelegant. 到目前为止我发现的所有内容都表明你只能通过一个看似不优雅的自定义URL处理程序来实现。

Yes, you can programmatically add entities as explained in the documentation ( Creating, Retrieving, Updating, and Deleting Entities ): 是的,您可以按照文档( 创建,检索,更新和删除实体 )中的说明以编程方式添加实体:

sandy = Account(username='Sandy', userid=123, email='sandy@example.com')
sandy_key = sandy.put()

You could implement your own fixtures by hard-coding all the data or reading it from a text file (as part of the deployment). 您可以通过对所有数据进行硬编码或从文本文件中读取(作为部署的一部分)来实现自己的灯具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM