|
@@ -23,38 +23,41 @@ class TaskMySQLClient(object):
|
|
|
初始化连接
|
|
|
:return:
|
|
|
"""
|
|
|
- match self.db_name:
|
|
|
- case "pq":
|
|
|
- self.mysql_pool = await aiomysql.create_pool(
|
|
|
- host='rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com',
|
|
|
- port=3306,
|
|
|
- user='crawler',
|
|
|
- password='crawler123456@',
|
|
|
- db='piaoquan-crawler',
|
|
|
- charset='utf8mb4',
|
|
|
- connect_timeout=120,
|
|
|
- )
|
|
|
- case "denet":
|
|
|
- self.mysql_pool = await aiomysql.create_pool(
|
|
|
- host='rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com',
|
|
|
- port=3306,
|
|
|
- user='crawler_admin',
|
|
|
- password='cyber#crawler_2023',
|
|
|
- db='aigc-admin-prod',
|
|
|
- charset='utf8mb4',
|
|
|
- connect_timeout=120,
|
|
|
- )
|
|
|
- case "long-article":
|
|
|
- self.mysql_pool = await aiomysql.create_pool(
|
|
|
- host='rm-bp14529nwwcw75yr1ko.mysql.rds.aliyuncs.com',
|
|
|
- port=3306,
|
|
|
- user='changwen_admin',
|
|
|
- password='changwen@123456',
|
|
|
- db='long_articles',
|
|
|
- charset='utf8mb4',
|
|
|
- connect_timeout=120,
|
|
|
- )
|
|
|
- print("mysql init successfully")
|
|
|
+ if self.db_name == 'pq':
|
|
|
+ self.mysql_pool = await aiomysql.create_pool(
|
|
|
+ host='rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com',
|
|
|
+ port=3306,
|
|
|
+ user='crawler',
|
|
|
+ password='crawler123456@',
|
|
|
+ db='piaoquan-crawler',
|
|
|
+ charset='utf8mb4',
|
|
|
+ connect_timeout=120,
|
|
|
+ )
|
|
|
+ print("mysql init successfully")
|
|
|
+ elif self.db_name == 'denet':
|
|
|
+ self.mysql_pool = await aiomysql.create_pool(
|
|
|
+ host='rm-t4na9qj85v7790tf84o.mysql.singapore.rds.aliyuncs.com',
|
|
|
+ port=3306,
|
|
|
+ user='crawler_admin',
|
|
|
+ password='cyber#crawler_2023',
|
|
|
+ db='aigc-admin-prod',
|
|
|
+ charset='utf8mb4',
|
|
|
+ connect_timeout=120,
|
|
|
+ )
|
|
|
+ print("mysql init successfully")
|
|
|
+ elif self.db_name == 'long-article':
|
|
|
+ self.mysql_pool = await aiomysql.create_pool(
|
|
|
+ host='rm-bp14529nwwcw75yr1ko.mysql.rds.aliyuncs.com',
|
|
|
+ port=3306,
|
|
|
+ user='changwen_admin',
|
|
|
+ password='changwen@123456',
|
|
|
+ db='long_articles',
|
|
|
+ charset='utf8mb4',
|
|
|
+ connect_timeout=120,
|
|
|
+ )
|
|
|
+ print("mysql init successfully")
|
|
|
+ else:
|
|
|
+ print("mysql init fail")
|
|
|
|
|
|
async def close_pool(self):
|
|
|
"""
|