3

I have been searching this since yesterday and still nothing. From all that researching this is my understanding so far.

  • You can access your datastore remotely with remote_api_shell.py
  • Make sure your path is set correctly in your Environment variable.

And according to my understanding the remote datastore that they were talking about is the datastore in appspot.com and not the local one. I don't want to deploy my app right now and hence I want to just work locally, for now atleast.

I created a model named Usersdb in my app. As someone coming from PHP, MYSQL background I thought GQL would have console environment for us to test the queries. But after some googling I found out that you can manipulate local datastore from the interactive console that's in

http://localhost:8081/_ah/admin/interactive

From the post Google App Engine GQL query on localhost I got the idea of performing GqlQuery in the interactive console while in localhost which goes something like this:-

from google.appengine.ext import db
q = db.GqlQuery("SELECT * FROM Userdb where username = 'random_user'")
print q.get().username

But what I really wanted to do was perform method calls like get_by_id() and get_by_key_name() and such in my interactive console without having to test on my app. Like:-

print Userdb.get_by_id(12)

How can I get those running? Do I have to import my python file to the interactive console? I tried doing that too but it crashed app engine. I'm just starting out on app engine. Forgive me if this is a completely stupid question.

4

1 回答 1

3

您应该将您编写的模型类导入交互式控制台的会话中。例如,如果您model.py的应用程序中有一个名为的文件,其中包含您的Userdb类,您可以在交互式控制台中编写以下内容:

import model

print model.Userdb.get_by_id(12)
于 2012-08-13T23:52:36.670 回答