Reputation: 73
I need to get all the databases stored in redis server using python-redis Thanks
Upvotes: 4
Views: 5098
Reputation: 73
i've tried this
import redis
ser = redis.Redis()
print ser.config_get('databases')
and the console return this
{}
and if i put this
import redis
ser = redis.StrictRedis()
print ser.config_get('databases')
it return this
ser = redis.StrictRedis()
AttributeError: 'module' object has no attribute 'StrictRedis'
Upvotes: 1
Reputation: 6931
Look here List All Redis Databases
Then in python you can do:
In [3]: r = redis.StrictRedis()
In [4]: r.config_get('databases')
Out[4]: {'databases': '16'}
In [5]: r.info('keyspace')
Out[5]: {'db0': {'avg_ttl': 0, 'expires': 0, 'keys': 4}}
Upvotes: 11