How to remove all elements in Redis [duplicate]












0
















This question already has an answer here:




  • How do I to flush redis db from python redis?

    2 answers




How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.



I've such this:



import redis
from pprint import pprint

cli = redis.Redis('localhost')

dict_ = { # dummy
'tags': {'module': 'voltage', 'station': 'SNMP'},
'metric_name': 'voltage',
'value': 222,
'time': '2018-11-13T15:25:09'
}
cli.hmset("pythonDict", dict_)

for key in cli.keys('prefix:*'): # Didn't work.
cli.delete(key)

pprint(cli.hgetall("pythonDict"))


Still, the previous data appeared from dict_.










share|improve this question













marked as duplicate by Community Nov 13 '18 at 14:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    0
















    This question already has an answer here:




    • How do I to flush redis db from python redis?

      2 answers




    How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.



    I've such this:



    import redis
    from pprint import pprint

    cli = redis.Redis('localhost')

    dict_ = { # dummy
    'tags': {'module': 'voltage', 'station': 'SNMP'},
    'metric_name': 'voltage',
    'value': 222,
    'time': '2018-11-13T15:25:09'
    }
    cli.hmset("pythonDict", dict_)

    for key in cli.keys('prefix:*'): # Didn't work.
    cli.delete(key)

    pprint(cli.hgetall("pythonDict"))


    Still, the previous data appeared from dict_.










    share|improve this question













    marked as duplicate by Community Nov 13 '18 at 14:16


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      0












      0








      0









      This question already has an answer here:




      • How do I to flush redis db from python redis?

        2 answers




      How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.



      I've such this:



      import redis
      from pprint import pprint

      cli = redis.Redis('localhost')

      dict_ = { # dummy
      'tags': {'module': 'voltage', 'station': 'SNMP'},
      'metric_name': 'voltage',
      'value': 222,
      'time': '2018-11-13T15:25:09'
      }
      cli.hmset("pythonDict", dict_)

      for key in cli.keys('prefix:*'): # Didn't work.
      cli.delete(key)

      pprint(cli.hgetall("pythonDict"))


      Still, the previous data appeared from dict_.










      share|improve this question















      This question already has an answer here:




      • How do I to flush redis db from python redis?

        2 answers




      How to remove all elements in Redis? I tried with the following snippet code from this post but didn't work.



      I've such this:



      import redis
      from pprint import pprint

      cli = redis.Redis('localhost')

      dict_ = { # dummy
      'tags': {'module': 'voltage', 'station': 'SNMP'},
      'metric_name': 'voltage',
      'value': 222,
      'time': '2018-11-13T15:25:09'
      }
      cli.hmset("pythonDict", dict_)

      for key in cli.keys('prefix:*'): # Didn't work.
      cli.delete(key)

      pprint(cli.hgetall("pythonDict"))


      Still, the previous data appeared from dict_.





      This question already has an answer here:




      • How do I to flush redis db from python redis?

        2 answers








      python redis






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 14:07









      Benyamin JafariBenyamin Jafari

      2,94632139




      2,94632139




      marked as duplicate by Community Nov 13 '18 at 14:16


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Community Nov 13 '18 at 14:16


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          1














          You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.






          share|improve this answer


























          • Thanks a lot. It works.

            – Benyamin Jafari
            Nov 13 '18 at 14:15











          • What is the difference between this line and cli.flushall() or cli.flushdb()?

            – Benyamin Jafari
            Nov 13 '18 at 14:18











          • The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands

            – Itamar Haber
            Nov 13 '18 at 21:00


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.






          share|improve this answer


























          • Thanks a lot. It works.

            – Benyamin Jafari
            Nov 13 '18 at 14:15











          • What is the difference between this line and cli.flushall() or cli.flushdb()?

            – Benyamin Jafari
            Nov 13 '18 at 14:18











          • The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands

            – Itamar Haber
            Nov 13 '18 at 21:00
















          1














          You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.






          share|improve this answer


























          • Thanks a lot. It works.

            – Benyamin Jafari
            Nov 13 '18 at 14:15











          • What is the difference between this line and cli.flushall() or cli.flushdb()?

            – Benyamin Jafari
            Nov 13 '18 at 14:18











          • The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands

            – Itamar Haber
            Nov 13 '18 at 21:00














          1












          1








          1







          You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.






          share|improve this answer















          You're storing in Redis an object (dict_) under the key called 'pythonDict'. Just call cli.delete("pythonDict") to delete it.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 14:17









          Benyamin Jafari

          2,94632139




          2,94632139










          answered Nov 13 '18 at 14:10









          Itamar HaberItamar Haber

          28.5k43760




          28.5k43760













          • Thanks a lot. It works.

            – Benyamin Jafari
            Nov 13 '18 at 14:15











          • What is the difference between this line and cli.flushall() or cli.flushdb()?

            – Benyamin Jafari
            Nov 13 '18 at 14:18











          • The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands

            – Itamar Haber
            Nov 13 '18 at 21:00



















          • Thanks a lot. It works.

            – Benyamin Jafari
            Nov 13 '18 at 14:15











          • What is the difference between this line and cli.flushall() or cli.flushdb()?

            – Benyamin Jafari
            Nov 13 '18 at 14:18











          • The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands

            – Itamar Haber
            Nov 13 '18 at 21:00

















          Thanks a lot. It works.

          – Benyamin Jafari
          Nov 13 '18 at 14:15





          Thanks a lot. It works.

          – Benyamin Jafari
          Nov 13 '18 at 14:15













          What is the difference between this line and cli.flushall() or cli.flushdb()?

          – Benyamin Jafari
          Nov 13 '18 at 14:18





          What is the difference between this line and cli.flushall() or cli.flushdb()?

          – Benyamin Jafari
          Nov 13 '18 at 14:18













          The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands

          – Itamar Haber
          Nov 13 '18 at 21:00





          The first deletes all databases, the other just the currently-selected database. The docs are at redis.io/commands

          – Itamar Haber
          Nov 13 '18 at 21:00



          Popular posts from this blog

          The Sandy Post

          Danny Elfman

          Pages that link to "Head v. Amoskeag Manufacturing Co."