import redis r = redis.Redis(host='192.168.110.252', port=6379, password='Jchl1528', db=1, socket_timeout=5) count = r.dbsize() r.flushdb() print('Flushed ' + str(count) + ' keys')