Skip to content

Commit 83570a7

Browse files
authored
Support for SELECT (#1825)
1 parent 3347888 commit 83570a7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

redis/commands/core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,13 @@ def swapdb(self, first, second, **kwargs):
780780
"""
781781
return self.execute_command("SWAPDB", first, second, **kwargs)
782782

783+
def select(self, index, **kwargs):
784+
"""Select the Redis logical database at index.
785+
786+
See: https://redis.io/commands/select
787+
"""
788+
return self.execute_command("SELECT", index, **kwargs)
789+
783790
def info(self, section=None, **kwargs):
784791
"""
785792
Returns a dictionary containing information about the Redis server

tests/test_commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,12 @@ def test_role(self, r):
695695
assert isinstance(r.role()[1], int)
696696
assert isinstance(r.role()[2], list)
697697

698+
@pytest.mark.onlynoncluster
699+
def test_select(self, r):
700+
assert r.select(5)
701+
assert r.select(2)
702+
assert r.select(9)
703+
698704
@pytest.mark.onlynoncluster
699705
def test_slowlog_get(self, r, slowlog):
700706
assert r.slowlog_reset()

0 commit comments

Comments
 (0)