I'm trying to delete all the keys from the users bucket and the blog bucket
because they are all created by my doctests. I don't want these in my
database (they are garbage.. essentially).

Shuhao


On Thu, Dec 15, 2011 at 9:40 AM, Jon Meredith <jmered...@basho.com> wrote:

> Hi Shuhau,
>
> Do you intentionally try and delete all of the keys from the users bucket?
>  The keys list is built from the keys in the blog and the users bucket.
>  Would changing the code to list the blog bucket, delete then verify before
> moving on to the users bucket do what you want?
>
> Jon
>
> On Wed, Dec 14, 2011 at 7:54 PM, Shuhao Wu <ad...@thekks.net> wrote:
>
>> I'm trying to delete all the keys i've created after running some
>> doctests. (I know i should be using the test server.. but it appears that i
>> need to be root to run that...)
>>
>> Here's the script:
>>
>> #!/usr/bin/python
>> if __name__ == "__main__":
>>   import doctest
>>   print "Running tests...."
>>   #doctest.testfile("README.md") # I commented this out because my
>> cleanup is not deleting...
>>   print "If nothing happened, success.. otherwise.. DEBUG HOUR!"
>>
>>   # Clean up
>>   import riak
>>   print "Clean up time!"
>>   client = riak.RiakClient()
>>   bucket = client.bucket("blog")
>>   keys = bucket.get_keys()
>>   bucket = client.bucket("users")
>>   keys.extend(bucket.get_keys())
>>   print "Keys to be cleaned: " + str(keys)
>>
>>   for key in keys:
>>     print ("Deleting %s..." % key), not bucket.get(key).delete().exists()
>>
>>   for key in keys:
>>     print "Verifying %s deleted: %s" % (key, not bucket.get(key).exists())
>>
>>   print "Deleted %d keys!" % len(keys)
>>
>>
>> Here's the output:
>>
>> Running tests....
>> If nothing happened, success.. otherwise.. DEBUG HOUR!
>> Clean up time!
>> Keys to be cleaned: [u'534c8cda268b11e1b1b68ca982440b40',
>> u'b8eb84e8268a11e195748ca982440b40', u'6fa5b678268a11e1bf8d8ca982440b40',
>> u'dada10a6268a11e1a0888ca982440b40', u'549e0e2a268a11e1be1e8ca982440b40',
>> u'4957347e268a11e196e68ca982440b40', u'c03e2df8268b11e1ae5e8ca982440b40',
>> u'ddadfe28268a11e1ad0b8ca982440b40', u'7d54bb7a268a11e187718ca982440b40']
>> Deleting 534c8cda268b11e1b1b68ca982440b40... True
>> Deleting b8eb84e8268a11e195748ca982440b40... True
>> Deleting 6fa5b678268a11e1bf8d8ca982440b40... True
>> Deleting dada10a6268a11e1a0888ca982440b40... True
>> Deleting 549e0e2a268a11e1be1e8ca982440b40... True
>> Deleting 4957347e268a11e196e68ca982440b40... True
>> Deleting c03e2df8268b11e1ae5e8ca982440b40... True
>> Deleting ddadfe28268a11e1ad0b8ca982440b40... True
>> Deleting 7d54bb7a268a11e187718ca982440b40... True
>> Verifying 534c8cda268b11e1b1b68ca982440b40 deleted: True
>> Verifying b8eb84e8268a11e195748ca982440b40 deleted: True
>> Verifying 6fa5b678268a11e1bf8d8ca982440b40 deleted: True
>> Verifying dada10a6268a11e1a0888ca982440b40 deleted: True
>> Verifying 549e0e2a268a11e1be1e8ca982440b40 deleted: True
>> Verifying 4957347e268a11e196e68ca982440b40 deleted: True
>> Verifying c03e2df8268b11e1ae5e8ca982440b40 deleted: True
>> Verifying ddadfe28268a11e1ad0b8ca982440b40 deleted: True
>> Verifying 7d54bb7a268a11e187718ca982440b40 deleted: True
>> Deleted 9 keys!
>>
>> I can run this multiple times and it doesn't delete it and always show
>> the exact same output... but if i open a separate python console and delete
>> one of these keys via the same method (create a client, get a bucket, get
>> the object via key, delete the object...), this will go down to 9 keys...
>>
>> What's wrong? I'm so confused by this thing..
>>
>> Shuhao
>>
>> _______________________________________________
>> riak-users mailing list
>> riak-users@lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>
>>
>
>
> --
> Jon Meredith
> Platform Engineering Manager
> Basho Technologies, Inc.
> jmered...@basho.com
>
>
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to