python - Mass insert with Redis fails with strange errors -


i playing redis mass import using pipe , have following python script:

mydata = "" mydata += "*4\r\n$4\r\nhset\r\n$%d\r\n%s\r\n$%d\r\n%s\r\n$%d\r\n%s\r\n" % (len('myhash'), 'myhash', len('myfield'), 'myfield', len('myvalue'), 'myvalue')  print mydata.rstrip() 

it produces:

$ python redis_test.py *4 $4 hset $6 myhash $7 myfield $7 myvalue 

output of piping:

$ python redis_test.py | redis-cli -h rnode -n 5 --pipe --pipe-timeout 1 data transferred. waiting last reply... err unknown command '2' err unknown command '$4' err wrong number of arguments 'echo' command err unknown command '$20' err unknown command '�˛�Ʃa\m���pm��x�[�' no replies 1 seconds: exiting. errors: 6, replies: 6 

although getting populate db, know what's causing errors?

rnode:6379[5]> keys * 1) "myhash" rnode:6379[5]> hgetall myhash 1) "myfield" 2) "myvalue" 

answer own question: didn't know needed final crlf, hence this:

print mydata.rstrip() 

became:

print mydata 

result:

$ python redis_test.py | redis-cli -h rnode -n 5 --pipe --pipe-timeout 10 data transferred. waiting last reply... last reply received server. errors: 0, replies: 1 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -