Commit a26a500c by fangxingjun

no message

parent 8a9da898
......@@ -18,6 +18,9 @@ if __name__ == '__main__':
d2 = f'0{d2}' if int(d2) < 10 else f'{d2}'
db_type = 'postgresql_14'
import_tb = f"{site_name}_bs_category_asin_detail_month_{d1}_{d2}"
if date_type == 'day':
import_tb = f"{site_name}_bs_category_asin_detail_day_{date_info.replace('-', '_')}"
query = f"""
select
id, asin, null as week, best_sellers_rank, created_time as created_at, updated_time as updated_at, last_herf, all_best_sellers_href
......
......@@ -4,6 +4,13 @@ import sys
sys.path.append(os.path.dirname(sys.path[0]))
from utils.secure_db_client import get_remote_engine
from datetime import datetime, timedelta
def is_saturday(date_str: str, fmt: str = "%Y-%m-%d") -> bool:
dt = datetime.strptime(date_str, fmt)
# weekday(): 周一=0 ... 周六=5 周日=6
return dt.weekday() == 5
site_name = sys.argv[1] # 参数1:站点
date_type = sys.argv[2] # 参数2:类型:day/week/4_week/month/quarter
......@@ -24,12 +31,18 @@ partition_dict = {
}
sql_query = f"select id, request_id, asin, tracking_since from keepa_finder_asin where 1=1 " \
f"and \$CONDITIONS"
engine.sqoop_raw_import(
query=sql_query,
hive_table=hive_table,
partitions=partition_dict,
m=1,
)
is_saturday_flag = is_saturday(date_info)
if is_saturday_flag:
print(f"{date_info}是周六, 因此需要进行导入")
engine.sqoop_raw_import(
query=sql_query,
hive_table=hive_table,
partitions=partition_dict,
m=1,
)
else:
print(f"{date_info}不是周六, 因此不需要进行导入")
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 to comment