kasavbere
kasavbere

Reputation: 6003

Manually add entity to empty Google App Engine DataStore

From the tutorial, which I confirmed by creating a simple project, the index.yaml file is auto-generated when a query is run. What I further observe is that until then the admin console (http://localhost:8080/_ah/admin/datastore) does not show the data-store.

My problem is this: I have a project for which data/entities are to be added manually through the datastore admin console. The website is only used to display/retrieve data, not to add data to the data-store.

How do I get my data-store to appear on the console so I can add data?

Yes, try retrieving from the empty data-store through the browser just so I can get the index.yaml to populate, etc. But that does not work.

Upvotes: 3

Views: 3602

Answers (3)

broofa
broofa

Reputation: 38102

On your development server you can use the interactive console to create/instantiate/save an entity, which should cause the entity class to appear in the datastore interface, like so:

from google.appengine.ext import ndb

class YourEntityModel(ndb.Model):
    pass

YourEntityModel().put()

Upvotes: 0

dragonx
dragonx

Reputation: 15143

The easiest way is probably just to create a small python script inside your project folder and create your entities in script. Assign it to a URL handler that you'll use once, then disable.

You can even do it from the python shell. It's very useful for debugging, but you'll need to set it up once. http://alex.cloudware.it/2012/02/your-app-engine-app-in-python-shell.html

In order to do the same on production, use the remote_api: https://developers.google.com/appengine/articles/remote_api

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599480

This is a very strange question.

The automatic creation of index.yaml only happens locally, and is simply to help you create that file and upload it to AppEngine. There is no automatic creation or update of that file once it's on the server: and as the documentation explains, no queries can be run unless the relevant index already exists in index.yaml.

Since you need indexes to run queries, you must create that file locally - either manually, or by running the relevant queries against your development datastore - then upload it along with your app.

However, this has nothing at all to do with whether the datastore viewer appears in the admin. Online, it will always show, but only entity kinds that actually have an instance in the store will be shown. The datastore viewer knows nothing about your models, it only knows about kinds that exist in the datastore.

Upvotes: 0

Related Questions