[Tutor] get key value from Redis instance
Silviu Chiric
silviuchiric at gmail.com
Sun May 27 14:31:26 EDT 2018
Dear all
I need to get the value of given key from Redis, or both key and value, the
below code snippet fails always, even the connection is okay
StrictRedis<ConnectionPool<Connection<host=
redis-15838.c44.us-east-1-2.ec2.cloud.redislabs.com,port=15838,db=0>>>
Connected!
My code
import redis
try:
conn = redis.StrictRedis( host='
redis-15838.c44.us-east-1-2.ec2.cloud.redislabs.com', port=15838,
password='DavidLavinia2')
print (conn)
conn.ping()
print ('Connected!')
print 'Set Record:', conn.set("best_car_ever", "Tesla Model S")
print 'Get Record:', conn.get("best_car_ever")
print 'Delete Record:', conn.delete("best_car_ever")
print 'Get Deleted Record:', conn.get("best_car_ever")
except Exception as ex:
print ('Error:', ex)
exit('Failed to connect, terminating.')
Thanks!
More information about the Tutor
mailing list