I find the wiki page about the commands, I can't find a command return
the currently selected db.
Is it need to add new command to return this info? corresponding with
the SELECT command.
Best Regards
litao cheng
- Demis
--
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.
from itertools import count
from redis import Redis, ResponseError
r = Redis()
try:
[r.select(x) and r.set('selected_db', x) for x in count()]
except ResponseError, e:
if not str(e) == 'invalid DB index':
raise e
>>> r.select(5)
'OK'
>>> r.get('selected_db')
5
> thanks Demis.
> I will save the selected db info in my client.
> :)
>
> On Sun, Mar 21, 2010 at 11:07 PM, mythz <demis....@gmail.com
> <mailto:demis....@gmail.com>> wrote:
>
> Generally I have not needed this as the Redis client that sets the
> database will know the 'selected database'.
> When you first connect to Redis, the initial database is '0', it will
> stay at '0' for the duration of the connection until its changed.
> This setting is 'per connection', so does not affect any new
> connections which will start at the default db of 0.
>
> - Demis
>
> On Mar 21, 3:26 am, litao cheng <litaoch...@gmail.com
> <mailto:litaoch...@gmail.com>> wrote:
> > hi, buddies.
> >
> > I find the wiki page about the commands, I can't find a command
> return
> > the currently selected db.
> > Is it need to add new command to return this info? corresponding
> with
> > the SELECT command.
> >
> > Best Regards
> >
> > litao cheng
>
> --
> 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
> <mailto:redi...@googlegroups.com>.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com
> <mailto:redis-db%2Bunsu...@googlegroups.com>.