Commit 5107ec0e by 刘豪

update new sql

parent 284c63ca
......@@ -2,9 +2,10 @@ import pymysql
from config.db import *
import pymongo as pm
import redis
from utils.db_handler import DBHandler
from extract.ex_base import Base
class ConnList:
class ConnList(Base):
@staticmethod
def Dashboard():
......@@ -179,10 +180,25 @@ class ConnList:
conf['db_name'], charset='utf8')
@staticmethod
def LocalLx():
conf = local_liexin
return pymysql.connect(str(conf['host']), conf['user'], conf['password'],
conf['db_name'], charset='utf8')
def LxDb():
# if ENV == "produce":
# db_name = "hunt2016"
# 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
def LocalRank():
......@@ -196,3 +212,9 @@ class ConnList:
return pymysql.connect(str(conf['host']), conf['user'], conf['password'],
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
# -*- 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 = {
'host': 'localhost',
......
......@@ -8,22 +8,22 @@ class ExDashboard(Base):
def email_list(self, condition):
# 筛选字段
con_str = super().condition_to_str(condition['condition'])
# 订单数据库
db = ConnList.Dashboard()
sql = "SELECT email \
FROM \
lie_email_list \
WHERE %s" \
% con_str
results = DBHandler.read(db=db, sql=sql)
# 结果格式转换为字典
final_result = super().result_to_list(results)
print('final_result', len(final_result))
return final_result
# con_str = super().condition_to_str(condition['condition'])
#
# # 订单数据库
# db = ConnList.Dashboard()
# sql = "SELECT email \
# FROM \
# lie_email_list \
# WHERE %s" \
# % con_str
# results = DBHandler.read(db=db, sql=sql)
#
# # 结果格式转换为字典
# final_result = super().result_to_list(results)
# print('final_result', len(final_result))
return ["hao@ichunt.com"]
"""
汇总订单数据
......
......@@ -178,7 +178,7 @@ class ExSkuExpose(Base):
'o.order_source not like \'%pf=-1%\'',
'o.order_source like \'%search%\'']}
ex_order = ExOrder('料号明细')
data = ex_order.order_items(where)
# data = ex_order.order_items(where)
# 遍历订单数据
# for row in data:
......
......@@ -15,7 +15,8 @@ class ExUser(Base):
col_str = super().col_to_str(col)
# 用户数据库
db = ConnList.Order()
# db = ConnList.Order()
db = ConnList.LxDb()
start_time = condition['start_time']
end_time = condition['end_time']
con_str = super().condition_to_str(condition['condition'])
......@@ -47,7 +48,7 @@ class ExUser(Base):
col_str = super().col_to_str(col)
# 用户数据库
db = ConnList.Order()
db = ConnList.LxDb()
start_time = condition['start_time']
end_time = condition['end_time']
con_str = super().condition_to_str(condition['condition'])
......@@ -76,7 +77,7 @@ class ExUser(Base):
col_str = super().col_to_str(col)
# 用户数据库
db = ConnList.Order()
db = ConnList.LxDb()
start_time = condition['start_time']
end_time = condition['end_time']
con_str = super().condition_to_str(condition['condition'])
......@@ -288,7 +289,8 @@ class ExUser(Base):
col_str = super().col_to_str(col)
# 用户数据库
db = ConnList.Order()
# db = ConnList.Order()
db = ConnList.LxDb()
sql = "SELECT %s \
FROM lie_test_ip"\
......
......@@ -582,11 +582,12 @@ class PiDaily:
start_time = 0
end_time = DateHandler.now_datetime()
db = ConnList.Order()
# db = ConnList.Order()
lx_order_db = ConnList.LxOrderDb()
wr_db = ConnList.WrCrm()
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))
ts_user.is_order()
......
......@@ -155,7 +155,7 @@ class TsUser(TsBase):
new_paid_amount = 0
old_amount = 0
old_paid_amount = 0
db = ConnList.Order()
db = ConnList.LxOrderDb()
for row in self.data:
user_id = row['user_id']
......
......@@ -26,8 +26,10 @@ class MsgHandler:
"content": msg
}
}
res = requests.post(robot_api + robot, json=data)
print(res)
# todo: 将注释改回来
print("send_dd_msg", data)
# res = requests.post(robot_api + robot, json=data)
# print(res)
@staticmethod
def send_point_dd_msg(msg, robot_api):
......@@ -37,8 +39,10 @@ class MsgHandler:
"content": msg
}
}
res = requests.post(robot_api, json=data)
print(res)
# todo: 将注释改回来
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