question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZADD throws error with dict

See original GitHub issue

While trying to add elements to a zset, I get the following error stacktrace

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    r.zadd("KEY", kwargs=dict)
  File "/Library/Python/2.7/site-packages/redis/client.py", line 2057, in zadd
    return self.execute_command('ZADD', name, *pieces)
  File "/Library/Python/2.7/site-packages/redis/client.py", line 573, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/Library/Python/2.7/site-packages/redis/client.py", line 585, in parse_response
    response = connection.read_response()
  File "/Library/Python/2.7/site-packages/redis/connection.py", line 582, in read_response
    raise response
redis.exceptions.ResponseError: value is not a valid float

The code I was trying to run was

import redis
r = redis.Redis(host='localhost', port=6379, db=2)

dict = {'akarshit': 1.1}
r.zadd("KEY", kwargs=dict)

Is there something I am missing or is this a bug with py-redis?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
andymccurdycommented, Aug 17, 2016

It should be:

r.zadd("KEY", **dict)
0reactions
kavin26commented, Apr 14, 2018

@andymccurdy hi… is the issue of redis.exceptions.RedisError: ZADD requires an equal number of values and scores when adding dict object, still open? I’m using redis version 3.0.6 connected using redis-python

Read more comments on GitHub >

github_iconTop Results From Across the Web

ZADD throws error with dict · Issue #771 · redis/redis-py - GitHub
I understand that the cause of error is that the zadd() expects a argument name= and while unpacking the dictionary the name from...
Read more >
not able to insert data using ZADD(sorted set ) in redis using ...
Instead of args/kwargs, a dict is expected, with key as data and value is the ZADD score. There are no changes in retrieving...
Read more >
Python Dict and File | Python Education - Google Developers
Looking up a value which is not in the dict throws a KeyError -- use "in" to check if the key is in...
Read more >
You're Probably Thinking About Redis Streams Wrong
Redis Head of Developer Advocacy Kyle Davis explains how you can leverage Redis Streams' less-understood properties in your applications.
Read more >
ZADD - Redis
If the key exists but does not hold a sorted set, an error is returned. The score values should be the string representation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found