123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import pymysql
- class DbMysql:
- cursor = None
- test = None
- def __init__(self):
- if self.cursor is None:
- host = 'rm-2zecd1ox47350846z885.mysql.rds.aliyuncs.com'
- user = 'bigdata_dy'
- password = 'douyindata1!'
- port = 3306
- self.db = pymysql.connect(
- host=host,
- user=user,
- password=password,
- database='brand_data',
- port=port,
- charset='utf8mb4'
- )
- # 使用cursor()方法获取操作游标
- self.cursor = self.db.cursor()
- def __test__(self):
- if self.test is None:
- host = 'rm-2zej6ys9n36kdfbq7o.mysql.rds.aliyuncs.com'
- user = 'test_db'
- password = 'Kuxuan1!'
- port = 3306
- self.db = pymysql.connect(
- host=host,
- user=user,
- password=password,
- database='brand_data',
- port=port,
- charset='utf8mb4'
- )
- # 使用cursor()方法获取操作游标
- self.test = self.db.cursor()
|