店播爬取Python脚本

db_redis.py 609B

123456789101112131415161718192021222324252627
  1. import redis
  2. class DbRedis:
  3. __connection = None
  4. @staticmethod
  5. def connect():
  6. if DbRedis.__connection is None:
  7. host = 'r-2ze28bdb7389a8a4614.redis.rds.aliyuncs.com'
  8. # host = 'r-2ze28bdb7389a8a4pd.redis.rds.aliyuncs.com'
  9. port = 6379
  10. password = 'Zhuaduoduo2017'
  11. DbRedis.__connection = redis.StrictRedis(
  12. host=host,
  13. port=port,
  14. password=password,
  15. decode_responses=True
  16. )
  17. print('Redis 连接成功!')
  18. return DbRedis.__connection