Issue
I want the store geospatial information in Redis. I am executing the following code
from redis import Redis
redis_con = Redis(host="localhost", port=6379)
redis_con.geoadd("Sicily", 13.361389, 38.115556, "Palermo")
But ı got error like that
raise DataError("GEOADD allows either 'nx' or 'xx', not both")
redis.exceptions.DataError: GEOADD allows either 'nx' or 'xx', not both
Solution
This will work for you:
from redis import Redis
redis_con = Redis(host="localhost", port=6379)
coords = (13.361389, 38.115556, "Palermo")
redis_con.geoadd("Sicily", coords)
The signature for geoadd
is:
geoadd(name, values, nx=False, xx=False, ch=False)
name: Union[bytes, str, memoryview]
values: Sequence[Union[bytes, memoryview, str, int, float]]
nx (bool, default: False)
xx (bool, default: False)
ch (bool, default: False)
You need to specify your coordinates as a sequence like a list
or tuple
, because right now you're specifying arguments so that the method thinks you've specified nx
, xx
, and ch
.
Answered By - wkl Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.