[英]How to get all the databases stored in redis using python
我需要使用python-redis获取存储在Redis服务器中的所有数据库
Look here List All Redis Databases 在这里列出所有Redis数据库
Then in python you can do: 然后在python中,您可以执行以下操作:
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}}
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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.