Redis mass insertion do not work
Question: Problem as simple as I want to do mass insertion in redis using a file and
redis-cli in pipe mode. Redis documentation explains this here:
<http://redis.io/topics/mass-insert>

My file contains only this command:

    
    
    HMSET client:1 name "Michael"
    

When I try it in my shell (Ubuntu Linux):

    
    
    cat data.txt | redis-cli --pipe
    

I get this error:

    
    
    ERR unknown command '$4'
    ERR wrong number of arguments for 'echo' command
    ERR unknown command '$20'
    

I've seen that other users have same problem ([How to use Redis mass
insertion?](http://stackoverflow.com/questions/13195341/how-to-use-redis-mass-
insertion)) but I haven't found a good solution.

Any help would be appreciated.

**UPDATE: SOLUTION**

Finally the best option for me was to use a redis client developed in Python.
This is a pretty straight forward solution, and the point is that we don't
need to use/code redis protocol directly.

I choose redis-py client (<https://github.com/andymccurdy/redis-py>). After
installing it you can import its functionality in your python script. This is
an example of how my script does the job:

    
    
    import redis
    
    # Connection to 0 database (default in redis)
    r = redis.Redis(host="localhost",db=0)
    
    # inserting client hashmaps
    r.hmset('client:1', {'name':'John', 'company':'Microsoft'})
    r.hmset('client:2', {'name':'James', 'company':'Apple'})
    
    # inserting a list of domains for client 1
    r.rpush('client:1:domains','www.microsoft.com','www.msn.com')
    
    #to print values in stdout
    print(r.hgetall('client:1'))
    


Answer: Your input file is supposed to contain Redis protocol, not text commands.

See an example here: [Redis Mass
Insertion](http://stackoverflow.com/questions/18870623/redis-mass-
insertion/18872283#18872283)

Redis protocol is described here: <http://redis.io/topics/protocol>

