Example of setting a hmset using the python api

10,234 views
Skip to first unread message

David Montgomery

unread,
Feb 10, 2012, 10:16:53 PM2/10/12
to redi...@googlegroups.com
Hi,

Given this HMSET myhash field1 "Hello" field2 "World" how do I use
tye python api to do the same thing? r.hmset(?,?)

Thanks

Josiah Carlson

unread,
Feb 11, 2012, 1:58:57 AM2/11/12
to redi...@googlegroups.com
r.hmset(name, {'field1':'Hello', 'field2':'World'})

Regards,
- Josiah

> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>

Josiah Carlson

unread,
Nov 3, 2012, 2:06:02 PM11/3/12
to redi...@googlegroups.com
If you just want to fetch all of the key names:
r.hkeys('blogtable_userDetails_John')
if you want all of the keys and values:
r.hgetall('blogtable_userDetails_John')

These are all standard Redis commands, which you can read about at:
http://redis.io/commands

Regards,
- Josiah

On Sat, Nov 3, 2012 at 7:32 AM, Sivaranjini D <dro...@gmail.com> wrote:
> Hi,
>
> In hmget command, how do I have print all fields for a key?
>
> import redis
> r = redis.Redis(host="localhost",db=1)
> r.hmset('blogtable_userDetails_John', {'password':'abcd',
> 'lastlogindate':'2012-20-9'})
> redirect = r.hmget(blogtable_userDetails_John','password')
> print(redirect)
>
> In the above eg, the values are printed for the field names that are passed.
> How is that I have to print all fields?
>
> Thanks,
> Ranjini
> To view this discussion on the web visit
> https://groups.google.com/d/msg/redis-db/-/RjobYZl5qtUJ.

Sivaranjini

unread,
Nov 4, 2012, 1:07:20 AM11/4/12
to redi...@googlegroups.com
Hi Josiah,

Thank you for the info :)

-Ranjini
Regards,
Sivaranjini
 
A cynic is a man who knows the price of everything but the value of nothing - Oscar Wilde

Reply all
Reply to author
Forward
0 new messages