Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I to flush redis db from python redis?

Tags:

python

redis

Is there a way I can flush my redis db using redis?

I'm looking for something like redis.flushdb() or redis.flushall()

like image 527
Dani Medina Avatar asked Aug 28 '17 09:08

Dani Medina


People also ask

How do I clear Redis in Python?

flushdb() # Delete all keys of currently selected database instance. r. flushall() # Delete all keys of entire database.

How do I flush a Redis database?

To clear data of a DCS Redis 4.0 or 5.0 instance, you can run the FLUSHDB or FLUSHALL command in redis-cli, use the data clearing function on the DCS console, or run the FLUSHDB command on Web CLI. To clear data of a Redis Cluster instance, run the FLUSHDB or FLUSHALL command on every shard of the instance.

What is Redis flush?

There are two major commands to delete the keys present in Redis: FLUSHDB and FLUSHALL. We can use the Redis CLI to execute these commands. The FLUSHDB command deletes the keys in a database. And the FLUSHALL command deletes all keys in all databases.

How do I flush all Redis keys?

In Redis you can flush cache/database and delete all keys from all databases or from the particular database only using FLUSHALL and FLUSHDB commands. To delete all keys from all Redis databases, use the FLUSHALL command. To delete all keys of the selected Redis database only, use the FLUSHDB commnad.


2 Answers

Redis-py actually has this functionality:

import redis r = redis.Redis() r.flushdb() 
like image 66
Aleksandr Borisov Avatar answered Sep 29 '22 11:09

Aleksandr Borisov


Yes, flushdb() and flushall() both exist.

check out this page, you will find them.

like image 35
GuangshengZuo Avatar answered Sep 29 '22 10:09

GuangshengZuo