Is there an easy way to reset the datastore ?

34 views
Skip to first unread message

Francois Masurel

unread,
Sep 12, 2010, 4:09:49 AM9/12/10
to Google App Engine
I just used the bulkloader to restore data from another GAE
application but sadly all string key references are erroneous (coz key
contains appid) and my restored entities are useless.

Do I have to erase my 32000 entities manually or is there an easier
way to reset the datastore ?

Thanx for your helpl.

Francois

Flips

unread,
Sep 12, 2010, 5:45:28 AM9/12/10
to Google App Engine

Tim Hoffman

unread,
Sep 12, 2010, 7:20:26 AM9/12/10
to Google App Engine
Hi

There is no need to use the mapper api for that small number of
entities

Use the console and remote api. It will only take a few minutes
runtime. And the advantage is you don't have to deploy anything as
long
as you have remote_api handler already registered.

The do a GQL query of GQL.query("select __key__")

then with a cursor, do a series of fetches of keys followed by
deletes.

For instance

def bulk_delete(kind=None):
c=None
q=None
i = 0
if kind:
q = kind.all(keys_only=True)
else:
q = db.GqlQuery("select __key__")

while True:

if c:
q.with_cursor(c)
keys = q.fetch(500)
i = i+len(keys)
if not keys:
return i
db.delete(keys)
c = q.cursor()


See ya

T

T

Francois Masurel

unread,
Sep 12, 2010, 1:38:58 PM9/12/10
to Google App Engine
Hi Tim,

Your solution seems to be interesting.

You say that I don't need to deploy anything as long as remote_api is
enabled and we can just use the console to do our deletes.

Could you explain a bit more how you do that ? My app is written in
java.

Thanx again.

Francois Masurel

unread,
Sep 12, 2010, 2:00:14 PM9/12/10
to Google App Engine
Found this thread :

http://groups.google.com/group/google-appengine/browse_thread/thread/59782fc263892c56/6db72b434a829776?lnk=gst&q=java+erase+datastore#6db72b434a829776

It confirms there is no easy solution to bulk delete entities.

May be it could be added to the bulkloader ?

Tim Hoffman

unread,
Sep 13, 2010, 1:56:39 AM9/13/10
to Google App Engine
Sorry can't help you with java, Never use it,

But you can use python on the console and access the datastore in the
same fashion.
Remember you can deploy python and java into appengine on different
versions and both can access the same data.
So the abstract datastore via remote_api is no different (entity wise)
for python or java.

Rgds

Tim
Reply all
Reply to author
Forward
0 new messages