Commit 5107ec0e by 刘豪

update new sql

parent 284c63ca
...@@ -2,9 +2,10 @@ import pymysql ...@@ -2,9 +2,10 @@ import pymysql
from config.db import * from config.db import *
import pymongo as pm import pymongo as pm
import redis import redis
from utils.db_handler import DBHandler
from extract.ex_base import Base
class ConnList(Base):
class ConnList:
@staticmethod @staticmethod
def Dashboard(): def Dashboard():
...@@ -179,10 +180,25 @@ class ConnList: ...@@ -179,10 +180,25 @@ class ConnList:
conf['db_name'], charset='utf8') conf['db_name'], charset='utf8')
@staticmethod @staticmethod
def LocalLx(): def LxDb():
conf = local_liexin # if ENV == "produce":
return pymysql.connect(str(conf['host']), conf['user'], conf['password'], # db_name = "hunt2016"
conf['db_name'], charset='utf8') # else:
# db_name = "liexin"
conf = {
'host': "172.18.137.22",
'port': 3306,
'user': "huntdbslave",
'password': "mLssy2@@!!@$#yy",
'db': "hunt2016",
'charset': 'utf8'
}
return pymysql.connect(**conf)
@staticmethod
def LxOrderDb():
conf = get_mysql_conf("liexin_order")
return pymysql.connect(**conf)
@staticmethod @staticmethod
def LocalRank(): def LocalRank():
...@@ -196,3 +212,9 @@ class ConnList: ...@@ -196,3 +212,9 @@ class ConnList:
return pymysql.connect(str(conf['host']), conf['user'], conf['password'], return pymysql.connect(str(conf['host']), conf['user'], conf['password'],
conf['db_name'], charset='utf8') conf['db_name'], charset='utf8')
@staticmethod
def handle_sql(db, col, sql_str):
results = DBHandler.read(db=db, sql=sql_str)
result_dict = super().result_to_dict(col, results)
return result_dict
\ No newline at end of file
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding:utf-8 -*- # -*- coding:utf-8 -*-
import sys
def get_env():
if sys.platform in ('darwin', 'win32'):
return 'test'
else:
return 'produce'
ENV = get_env()
def get_mysql_conf(db):
if ENV == 'produce':
user, psd = 'Usorder', 'OdsLssy2@@!!@$#yy2'
host = 'business-master.ichunt.db'
else:
host = '192.168.1.252'
user, psd = 'liexin', 'liexin#zsyM'
conf = {
'host': host,
'port': 3306,
'user': user,
'password': psd,
'db': db,
'charset': 'utf8'
}
return conf
dashboard_server = { dashboard_server = {
'host': 'localhost', 'host': 'localhost',
......
...@@ -8,22 +8,22 @@ class ExDashboard(Base): ...@@ -8,22 +8,22 @@ class ExDashboard(Base):
def email_list(self, condition): def email_list(self, condition):
# 筛选字段 # 筛选字段
con_str = super().condition_to_str(condition['condition']) # con_str = super().condition_to_str(condition['condition'])
#
# 订单数据库 # # 订单数据库
db = ConnList.Dashboard() # db = ConnList.Dashboard()
sql = "SELECT email \ # sql = "SELECT email \
FROM \ # FROM \
lie_email_list \ # lie_email_list \
WHERE %s" \ # WHERE %s" \
% con_str # % con_str
results = DBHandler.read(db=db, sql=sql) # results = DBHandler.read(db=db, sql=sql)
#
# 结果格式转换为字典 # # 结果格式转换为字典
final_result = super().result_to_list(results) # final_result = super().result_to_list(results)
print('final_result', len(final_result)) # print('final_result', len(final_result))
return final_result return ["hao@ichunt.com"]
""" """
汇总订单数据 汇总订单数据
......
...@@ -178,7 +178,7 @@ class ExSkuExpose(Base): ...@@ -178,7 +178,7 @@ class ExSkuExpose(Base):
'o.order_source not like \'%pf=-1%\'', 'o.order_source not like \'%pf=-1%\'',
'o.order_source like \'%search%\'']} 'o.order_source like \'%search%\'']}
ex_order = ExOrder('料号明细') ex_order = ExOrder('料号明细')
data = ex_order.order_items(where) # data = ex_order.order_items(where)
# 遍历订单数据 # 遍历订单数据
# for row in data: # for row in data:
......
...@@ -15,7 +15,8 @@ class ExUser(Base): ...@@ -15,7 +15,8 @@ class ExUser(Base):
col_str = super().col_to_str(col) col_str = super().col_to_str(col)
# 用户数据库 # 用户数据库
db = ConnList.Order() # db = ConnList.Order()
db = ConnList.LxDb()
start_time = condition['start_time'] start_time = condition['start_time']
end_time = condition['end_time'] end_time = condition['end_time']
con_str = super().condition_to_str(condition['condition']) con_str = super().condition_to_str(condition['condition'])
...@@ -47,7 +48,7 @@ class ExUser(Base): ...@@ -47,7 +48,7 @@ class ExUser(Base):
col_str = super().col_to_str(col) col_str = super().col_to_str(col)
# 用户数据库 # 用户数据库
db = ConnList.Order() db = ConnList.LxDb()
start_time = condition['start_time'] start_time = condition['start_time']
end_time = condition['end_time'] end_time = condition['end_time']
con_str = super().condition_to_str(condition['condition']) con_str = super().condition_to_str(condition['condition'])
...@@ -76,7 +77,7 @@ class ExUser(Base): ...@@ -76,7 +77,7 @@ class ExUser(Base):
col_str = super().col_to_str(col) col_str = super().col_to_str(col)
# 用户数据库 # 用户数据库
db = ConnList.Order() db = ConnList.LxDb()
start_time = condition['start_time'] start_time = condition['start_time']
end_time = condition['end_time'] end_time = condition['end_time']
con_str = super().condition_to_str(condition['condition']) con_str = super().condition_to_str(condition['condition'])
...@@ -288,7 +289,8 @@ class ExUser(Base): ...@@ -288,7 +289,8 @@ class ExUser(Base):
col_str = super().col_to_str(col) col_str = super().col_to_str(col)
# 用户数据库 # 用户数据库
db = ConnList.Order() # db = ConnList.Order()
db = ConnList.LxDb()
sql = "SELECT %s \ sql = "SELECT %s \
FROM lie_test_ip"\ FROM lie_test_ip"\
......
...@@ -582,11 +582,12 @@ class PiDaily: ...@@ -582,11 +582,12 @@ class PiDaily:
start_time = 0 start_time = 0
end_time = DateHandler.now_datetime() end_time = DateHandler.now_datetime()
db = ConnList.Order() # db = ConnList.Order()
lx_order_db = ConnList.LxOrderDb()
wr_db = ConnList.WrCrm() wr_db = ConnList.WrCrm()
user = ExCrm('').crm_user(start_time, end_time) user = ExCrm('').crm_user(start_time, end_time)
ts_user = TsCrm(db, wr_db, user) ts_user = TsCrm(lx_order_db, wr_db, user)
print(len(user)) print(len(user))
ts_user.is_order() ts_user.is_order()
......
...@@ -155,7 +155,7 @@ class TsUser(TsBase): ...@@ -155,7 +155,7 @@ class TsUser(TsBase):
new_paid_amount = 0 new_paid_amount = 0
old_amount = 0 old_amount = 0
old_paid_amount = 0 old_paid_amount = 0
db = ConnList.Order() db = ConnList.LxOrderDb()
for row in self.data: for row in self.data:
user_id = row['user_id'] user_id = row['user_id']
......
...@@ -26,8 +26,10 @@ class MsgHandler: ...@@ -26,8 +26,10 @@ class MsgHandler:
"content": msg "content": msg
} }
} }
res = requests.post(robot_api + robot, json=data) # todo: 将注释改回来
print(res) print("send_dd_msg", data)
# res = requests.post(robot_api + robot, json=data)
# print(res)
@staticmethod @staticmethod
def send_point_dd_msg(msg, robot_api): def send_point_dd_msg(msg, robot_api):
...@@ -37,8 +39,10 @@ class MsgHandler: ...@@ -37,8 +39,10 @@ class MsgHandler:
"content": msg "content": msg
} }
} }
res = requests.post(robot_api, json=data) # todo: 将注释改回来
print(res) print("send_point_dd_msg", data)
# res = requests.post(robot_api, json=data)
# print(res)
""" """
调用消息接口发送邮件 调用消息接口发送邮件
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment