Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all the databases stored in redis using python

I need to get all the databases stored in redis server using python-redis Thanks

like image 543
EdWarD Avatar asked Oct 20 '25 14:10

EdWarD


2 Answers

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}}
like image 177
eran Avatar answered Oct 23 '25 07:10

eran


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'
like image 45
EdWarD Avatar answered Oct 23 '25 08:10

EdWarD