Created
April 17, 2013 14:57
-
-
Save westhood/5404986 to your computer and use it in GitHub Desktop.
Use redis-cli to insert massive data in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| p = subprocess.Popen(["redis-cli", "--pipe"], | |
| stdin=subprocess.PIPE) | |
| for x in xrange(0, 100): | |
| # write to redis-cli stdin in redis protocol | |
| p.stdin.write("set %s %s\r\n" % (x, x + 1) | |
| p.stdin.close() | |
| p.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment