from .client import Client
[docs]class Connection(Client):
[docs] def auth(self, password): # pragma: no cover
"""
Authenticate to the server
Parameters
----------
password : str
The password to authenticate with
"""
return self.execute_command('AUTH', password)
[docs] def echo(self, *args):
"""Echo the given string
Parameters
----------
message : str
The string to echo
"""
return self.execute_command('ECHO', *args)
[docs] def ping(self, *args):
"""Ping the server"""
try:
result = self.execute_command('PING', *args)
except:
result = None
if result == b'PONG':
return True
return False
[docs] def select(self, *args): # pragma: no cover
"""
Change the selected database
Parameters
----------
index : int
The redis database number to switch to
"""
return self.execute_command('SELECT', *args)
[docs] def quit(self, *args):
"""Close the connection"""
return self.execute_command('QUIT', *args)