店播爬取Python脚本

db_mysql.py 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import pymysql
  2. class DbMysql:
  3. cursor = None
  4. test = None
  5. def __init__(self):
  6. if self.cursor is None:
  7. host = 'rm-2zecd1ox47350846z885.mysql.rds.aliyuncs.com'
  8. user = 'bigdata_dy'
  9. password = 'douyindata1!'
  10. port = 3306
  11. self.db = pymysql.connect(
  12. host=host,
  13. user=user,
  14. password=password,
  15. database='brand_data',
  16. port=port,
  17. charset='utf8mb4'
  18. )
  19. # 使用cursor()方法获取操作游标
  20. self.cursor = self.db.cursor()
  21. def __test__(self):
  22. if self.test is None:
  23. host = 'rm-2zej6ys9n36kdfbq7o.mysql.rds.aliyuncs.com'
  24. user = 'test_db'
  25. password = 'Kuxuan1!'
  26. port = 3306
  27. self.db = pymysql.connect(
  28. host=host,
  29. user=user,
  30. password=password,
  31. database='brand_data',
  32. port=port,
  33. charset='utf8mb4'
  34. )
  35. # 使用cursor()方法获取操作游标
  36. self.test = self.db.cursor()