Password connection string
abulte opened this issue · 3 comments
Hi,
I'm having trouble configuring a stdnet/redis connection with a login/password.
I tried this:
odm.register(Build, 'redis://root:redispasswd@localhost:6379?db=1')
Which gives me:
File "/home/vagrant/pyenv/local/lib/python2.7/site-packages/stdnet/lib/redis/connection.py", line 363, in connect
raise RedisConnectionError(self._error_message(e))
RedisConnectionError: Error 2 connecting root:redispasswd@localhost:6379. No such file or directory.
By the way, there is a problem in doc at http://lsbardel.github.com/python-stdnet/api/models.html#register. If you put a slash after the host name, you will get:
File "/home/vagrant/pyenv/local/lib/python2.7/site-packages/stdnet/backends/main.py", line 38, in parse_backend
Found {0}".format(path))
stdnet.exceptions.ImproperlyConfigured: Backend URI must not have a path. Found /?db=1
can you try
odm.register(Build, 'redis://localhost:6379?db=1&password=redispasswd')
Yes I'm aware of the slash issue. Not a critical issue to release a 0.7.1 though.
It is fixed in master which will be version 0.8 quite soon.
It works with this connection string format, thanks!
If it is not already done, this would be a nice addition to the docs.
By the way, I've run into this problem in one of my environments with the following stacktrace before narrowing it down to the connection string format. No idea why, but it may help...
File "stdnet/odm/base.py", line 522, in save
t.add(self)
File "stdnet/odm/session.py", line 384, in __exit__
result = self.commit()
File "stdnet/odm/session.py", line 407, in commit
return self.backend.execute_session(self.session, self.post_commit)
File "stdnet/backends/redisb.py", line 831, in execute_session
command, result = redis_execution(pipe, session_result)
File "stdnet/backends/redisb.py", line 139, in redis_execution
results = pipe.execute(load_script=True)
File "stdnet/lib/redis/client.py", line 1304, in execute
return self.request(load_script).execute()
File "stdnet/lib/redis/connection.py", line 217, in execute
self.connection.connect(self)
File "stdnet/lib/redis/connection.py", line 359, in connect
sock.settimeout(self.socket_timeout)
UnboundLocalError: local variable 'sock' referenced before assignment