From f3e0bceac2792b8185933ff6aaf43c57ec351ad5 Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Wed, 22 Dec 2021 11:46:22 +0200 Subject: [PATCH] Support for SELECT --- redis/commands/core.py | 7 +++++++ tests/test_commands.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/redis/commands/core.py b/redis/commands/core.py index 835ea6125a..eafd2361db 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -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 diff --git a/tests/test_commands.py b/tests/test_commands.py index b8dc69f9eb..bf94f62ce8 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -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()