|
@@ -11,18 +11,29 @@ from common.common import Common
|
|
|
|
|
|
class MysqlHelper:
|
|
|
@classmethod
|
|
|
- def connect_mysql(cls, env):
|
|
|
+ def connect_mysql(cls, env, action):
|
|
|
if env == 'hk':
|
|
|
-
|
|
|
- connection = pymysql.connect(
|
|
|
- host="rm-j6cz4c6pt96000xi3.mysql.rds.aliyuncs.com",
|
|
|
-
|
|
|
- port=3306,
|
|
|
- user="crawler",
|
|
|
- passwd="crawler123456@",
|
|
|
- db="piaoquan-crawler",
|
|
|
-
|
|
|
- charset="utf8")
|
|
|
+ if action == 'get_author_map':
|
|
|
+
|
|
|
+ connection = pymysql.connect(
|
|
|
+ host="rm-bp1159bu17li9hi94ro.mysql.rds.aliyuncs.com",
|
|
|
+ port=3306,
|
|
|
+ user="crawler",
|
|
|
+ passwd="crawler123456@",
|
|
|
+ db="piaoquan-crawler",
|
|
|
+
|
|
|
+ charset="utf8")
|
|
|
+ else:
|
|
|
+
|
|
|
+ connection = pymysql.connect(
|
|
|
+ host="rm-j6cz4c6pt96000xi3.mysql.rds.aliyuncs.com",
|
|
|
+
|
|
|
+ port=3306,
|
|
|
+ user="crawler",
|
|
|
+ passwd="crawler123456@",
|
|
|
+ db="piaoquan-crawler",
|
|
|
+
|
|
|
+ charset="utf8")
|
|
|
elif env == 'prod':
|
|
|
|
|
|
connection = pymysql.connect(
|
|
@@ -49,10 +60,10 @@ class MysqlHelper:
|
|
|
return connection
|
|
|
|
|
|
@classmethod
|
|
|
- def get_values(cls, log_type, crawler, sql, env):
|
|
|
+ def get_values(cls, log_type, crawler, sql, env, action=''):
|
|
|
try:
|
|
|
|
|
|
- connect = cls.connect_mysql(env)
|
|
|
+ connect = cls.connect_mysql(env, action)
|
|
|
|
|
|
mysql = connect.cursor(cursor=pymysql.cursors.DictCursor)
|
|
|
|