| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- from dao import Mysql
- def load_order_data_from_mysql(city_uuid):
- """从数据库中读取订单数据"""
- client = Mysql()
- tablename = "tads_brandcul_cust_order"
- query_text = "*"
- city_uuid = "00000000000000000000000011441801"
- df = client.load_data(tablename, query_text, "city_uuid", city_uuid)
- # df = client.load_mock_data(tablename, query_text)
- if len(df) == 0:
- return None
-
- df.drop('stat_month', axis=1, inplace=True)
- df.drop('city_uuid', axis=1, inplace=True)
-
- # 去除重复值和填补缺失值
- df.drop_duplicates(inplace=True)
- df.fillna(0, inplace=True)
- return df
- def load_cust_data_from_mysql(city_uuid):
- """从数据库中读取商户信息数据"""
- client = Mysql()
- tablename = "tads_brandcul_cust_info"
- query_text = "*"
-
- df = client.load_data(tablename, query_text, "BA_CITY_ORG_CODE", city_uuid)
- if len(df) == 0:
- return None
-
- return df
- def load_product_data_from_mysql(city_uuid):
- """从数据库中读取商品信息"""
- client = Mysql()
- tablename = "tads_brandcul_product_info"
- query_text = "*"
-
- df = client.load_data(tablename, query_text, "city_uuid", city_uuid)
- if len(df) == 0:
- return None
-
- return df
- def get_product_by_id(city_uuid, product_id):
- client = Mysql()
-
- res = client.get_product_by_id(city_uuid, product_id)
- if len(res) == 0:
- return None
- return res
- def get_custs_by_ids(city_uuid, cust_ids):
- client = Mysql()
-
- res = client.get_cust_by_ids(city_uuid, cust_ids)
- if len(res) == 0:
- return None
- return res
- if __name__ == '__main__':
- data = load_order_data_from_mysql("00000000000000000000000011445301")
- print(data)
|