Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redis-python db=0 parameter used for?

Tags:

redis

redis-py

I have read the redis-python document and searched online, I can not find anything about the db parameter for Redis(). What is it use for?

like image 965
kun Avatar asked Jun 24 '14 16:06

kun


People also ask

What is DB number in Redis?

Redis databases are numbered from 0 to 15 and, by default, you connect to database 0 when you connect to your Redis instance. However, you can change the database you're using with the select command after you connect: select 15.

What is db0 in Redis?

That's why db parameter is used. When we start redis-cli it's show or used 0 index logical database. If you want to change the default 0 index database run this command select 1 #index 1 logical database selected. After this we can run different commands specific to selected database.

What is Redis Python used for?

Redis is an in-memory key-value pair database typically classified as a NoSQL database. Redis is commonly used for caching, transient data storage and as a holding area for data during analysis in Python applications. Redis is an implementation of the NoSQL database concept.


2 Answers

By default, redis has 16 databases, which can be addressed by their indexes. This is what it's for.

See SELECT command.

like image 74
Sergio Tulentsev Avatar answered Sep 18 '22 12:09

Sergio Tulentsev


Redis by default consists of 16 logical databases. Starting from 0 index and ending with 15.

That's why db parameter is used.

When we start redis-cli it's show or used 0 index logical database.

If you want to change the default 0 index database run this command select 1 #index 1 logical database selected

After this we can run different commands specific to selected database. In our case we are using 1 index logical database.

flushdb swapdb

Note In redis cluster we can't used select command and only support 0 database.

like image 40
Muhammad Faizan Fareed Avatar answered Sep 19 '22 12:09

Muhammad Faizan Fareed