Вопрос

this is my first question on stackoverflow and I'm new to programming:

What is the right way to load data into the GAE datastore when deploying my app? This should only happen once at deployment.

In other words: How can I call methods in my code, such that these methods are only called when I deploy my app?

The GAE documentation for python2.7 says, that one shouldn't call a main function, so I can't do this:

if __name__ == '__main__':
   initialize_datastore()
   main()
Это было полезно?

Решение

Create a handler that is restricted to admins only. When that handler is invoked with a simple GET request you could have it check to see if the seed data exists and if it doesn't, insert it.

Configuring a handler to require login or administrator status.

Another option is to write a Python script that utilizes the Remote API. This would allow you to access local data sources such as a CSV file or a locally hosted database and wouldn't require you to create a potentially unwieldy handler.

Read about the Remote API in the docs.

Using the Remote API Shell - Google App Engine

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top