#!/usr/bin/env python
# coding=utf-8
# -*- coding=utf-8
import sys
import logging
import json
import datetime
import os
dir_path="sourcesql/"
today_time = (datetime.datetime.now()+datetime.timedelta(days=-1)).strftime("%Y-%m-%d")
temp_today_time=today_time.replace("-","_")
str_temp='''
LOAD LABEL test_{}_test
(
PROPERTIES
(
'timeout'='1200',
'max_filter_ratio'='0.1'
);
'''.format(temp_today_time,today_time)
print(str_temp)
os.popen("echo " +'\"'+ str_temp + '\"' +" > "+ dir_path + "test_{}_1.sql".format(today_time))
source_str="source "+dir_path+"test_{}_1.sql".format(today_time)
res_sql="mysql -h IP地址 -P 端口 -u账号 -p密码 数据库 -e "+ '\"'+source_str+'\"'
print(res_sql)
os.popen(res_sql)
具体中间的编写方法参照官网
https://doris.apache.org/zh-CN/docs/dev/data-operate/import/import-way/broker-load-manual