- main.py文件
from faker import Faker
import time
from clickhouse_driver import Client
f = Faker(locale='zh_CN')
start_time = time.time()
def re_list(start: int, setup: int, header=False):
l = [{
"ID": i + start * setup,
"Name": f.name(),
"Address": f.address(),
"Ssn": f.ssn(),
"Company": f.company(),
"Job": f.job(),
"Email": f.email(),
"Url": f.domain_name(),
"Card": f.credit_card_number(),
"PhoneNumber": f.phone_number(),
"UserName": f.user_name(),
"Password": f.password(),
"HeadImg": f.image_url(),
} for i in range(0, setup)]
print(l)
client = Client(host="xxxxxxx.cn", port=9000, user="xxxx", password="xxxx", database="xxxxx")
# client.execute('INSERT INTO test.upload_data_2_clickhouse (x) VALUES', [[200]])
client.execute('INSERT INTO test.upload_data_2_clickhouse (ID, Name, Address, Ssn, Company, Job, Email, Url, Card, PhoneNumber, UserName, Password, HeadImg) VALUES', l)
# select查询
# result = client.execute("select * from test.upload_data_2_clickhouse limit 10")
print(time.time() - start_time)
if __name__ == '__main__':
for i in range(0, 1):
re_list(i, 1)
re_list(0, 1)
- Dockerfile文件
FROM python:3.8
WORKDIR /usr/src/app
COPY ./test01 .
RUN python3 -m pip install --no-cache-dir -U -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
CMD ["/bin/bash", "-c", "/usr/src/app/run.sh"]
- run.sh文件
#!/bin/bash
python ./main.py
- requirements.txt文件
clickhouse-driver
faker
clickhouse-driver官网
faker官网