Thursday, September 30, 2010

Manipulate AppEngine datastore from the Python interactive console

# wednesday june 23, 2010 11:39 pm
# Victor N.

import sys
import code

gaedir = 'path/to/gae'

sys.path.append(gaedir)
sys.path.append(gaedir + '/lib/yaml/lib')
sys.path.append(gaedir + '/lib/webob')
sys.path.append(gaedir + '/lib/django')
sys.path.append(gaedir + '/lib/fancy_urllib')

extra = 'path/to/extra/libs'
sys.path.append(extra)

from google.appengine.ext.remote_api import remote_api_stub


def auth_func():
return 'da_username', 'da_password'


def main():
if len(sys.argv) < 2:
print 'Usage: %s app_id [host]' % sys.argv[0]
return

app_id = sys.argv[1]

if len(sys.argv) > 2: host = sys.argv[2]
else: host = '%s.appspot.com' % app_id

remote_api_stub.ConfigureRemoteDatastore(
app_id,
'/remote_api',
auth_func,
host
)

code.interact(
'App Engine interactive console for %s' % (app_id,),
None,
locals()
)


if __name__ == '__main__':
main()

now you just do:

python the_script_name.py your_app_name

you know who to blame if it does not work for you.

semper fi.

1 comment:

PanosJee said...

nice title!
I happen to write AppEngine and I come from Sparta, Laconia :D