How do I get all the keys that are stored in the Cassandra column family with pycassa?

Switch picture Switch · Mar 12, 2010 · Viewed 7.7k times · Source

Is anyone having experience working with pycassa I have a doubt with it. How do I get all the keys that are stored in the database?

well in this small snippet we need to give the keys in order to get the associated columns (here the keys are 'foo' and 'bar'),that is fine but my requirement is to get all the keys (only keys) at once as Python list or similar data structure.

cf.multiget(['foo', 'bar'])
{'foo': {'column1': 'val2'}, 'bar': {'column1': 'val3', 'column2': 'val4'}}

Thanks.

Answer

Jim Carroll picture Jim Carroll · Mar 29, 2010

try:

    list(cf.get_range().get_keys())

more good stuff here: http://github.com/vomjom/pycassa