Redis uses a database model in which you can select a database using the SELECT command. By default, Redis has 16 databases numbered from 0 to 15.
To list all the databases in Redis, you can use the “INFO” command along with “keyspace”.
$ redis-cli INFO keyspace
This command will return the information about all the databases, the output will be like:
db0:keys=2,expires=0
db1:keys=3,expires=0
db2:keys=1,expires=0
In python redis library
import redis
r = redis.Redis()
dbs = r.info("keyspace")
This will return a dictionary containing the information of all the databases.
Please note that the number of databases in Redis can be set in the configuration file, but the default is 16, and you can switch between them using the SELECT command by specifying the database number.