I am using Redis to store two databases : 0 and 1 via the Redis-py client library. I would like to create two connections for each database. Currently, I am doing this :
>>> connection0 = redis.Connection(host = 'localhost', port = 6379, db = 0)
>>> connection1 = redis.Connection(host = 'localhost', port = 6379, db = 1)
>>> connection0.connect()
However, I don't seem to find a way to create a Redis object from the connection.
>>> store0 = redis.Redis(connection0)
>>> store0.info()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/redis-2.4.11-py2.7.egg/redis/client.py", line 341, in info
return self.execute_command('INFO')
File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/redis-2.4.11-py2.7.egg/redis/client.py", line 278, in execute_command
connection.send_command(*args)
File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/redis-2.4.11-py2.7.egg/redis/connection.py", line 258, in send_command
self.send_packed_command(self.pack_command(*args))
File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/redis-2.4.11-py2.7.egg/redis/connection.py", line 241, in send_packed_command
self.connect()
File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/redis-2.4.11-py2.7.egg/redis/connection.py", line 187, in connect
sock = self._connect()
File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/redis-2.4.11-py2.7.egg/redis/connection.py", line 198, in _connect
sock.connect((self.host, self.port))
File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
TypeError: coercing to Unicode: need string or buffer, Connection found
Am I making a rookie mistake here?