Install redis in python and use python to operate the redis database. first download the redis-py module github. comandymccurdyredis-pyshell # wgetgit... install redis in python
Redis database operations with python, first download redis-py module https://github.com/andymccurdy/redis-py
Shell # wget https://github.com/andymccurdy/redis-py
Decompress the package
Run the python setup. py install installation module in the extract directory.
Installation complete
Usage:
Import redis
R = redis. Redis (host = 'localhost', port = 6379, db = 0)
R ['test'] = 'test' # or you can set the key in r. set ('test', 'test ').
R. get ('test') # obtain the value of test
R. delete ('test') # delete this key
R. flushdb () # clear the database
R. keys () # List all keys
R. exists ('test') # check whether this key exists
R. dbsize () # Number of items in the database