title: Redis: How to HMSET a dictionary from a Lua script?
body: <p>I am trying to pass a Python dict as an argument to a Lua script and <code>HMSET</code> it to a Redis key from the script.</p>
  
  <p>I have two questions.</p>
  
  <p><strong>How am I supposed to pass the dict from Python to Lua script and from the Lua script to Redis?</strong></p>
  
  <p>Passing it to Lua seems straightforward, with a <code>json.dumps()</code>. However, how do I convert it back to a dict (or Lua table I guess?) in Lua (I can not use Lua's <code>require</code> inside Redis' <code>EVAL</code>).</p>
  
  <p>Although I still don't know how to pass a real dict to Redis from Lua, I am still playing with <code>HMSET</code> inside the Lua script and trying to assign to the key a string.</p>
  
  <p><strong>Why am I getting this error:</strong></p>
  
  <pre><code>redis.exceptions.ResponseError: Error running script (call to f_2591f0a1987b36dd027b752af3591c92be845cd4):
  @user_script:7: @user_script: 7: Wrong number of args calling Redis command From Lua script
  </code></pre>
  
  <p>provided that my Lua code uses the same number of args as my Python <code>HMSET</code>:</p>
  
  <pre><code>local key_name = KEYS[1]
  redis.call('hmset', key_name, "some_val")
  </code></pre>