Skip to content

Support for SELECT #1825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,13 @@ def swapdb(self, first, second, **kwargs):
"""
return self.execute_command("SWAPDB", first, second, **kwargs)

def select(self, index, **kwargs):
"""Select the Redis logical database at index.

See: https://redis.io/commands/select
"""
return self.execute_command("SELECT", index, **kwargs)

def info(self, section=None, **kwargs):
"""
Returns a dictionary containing information about the Redis server
Expand Down
6 changes: 6 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,12 @@ def test_role(self, r):
assert isinstance(r.role()[1], int)
assert isinstance(r.role()[2], list)

@pytest.mark.onlynoncluster
def test_select(self, r):
assert r.select(5)
assert r.select(2)
assert r.select(9)

@pytest.mark.onlynoncluster
def test_slowlog_get(self, r, slowlog):
assert r.slowlog_reset()
Expand Down