提交代码

This commit is contained in:
halliday 2023-10-25 18:38:23 +08:00
parent 1387df9fff
commit f10f61392d
5 changed files with 71 additions and 5 deletions

61
bin/SQLDataCreating.py Normal file
View File

@ -0,0 +1,61 @@
# -*- coding:utf-8 -*-
import _load
import faker_data
import yaml
import codecs
import jaydebeapi
from schedule import every, repeat, run_pending
from pathlib import Path
from datetime import datetime
# 定义公共的部分
path = Path(__file__)
configfile = path.parent.parent / "etc/test_config.yml"
db_config = yaml.load(codecs.open(configfile ,'r',encoding='utf-8'),Loader=yaml.FullLoader)
driver_name = db_config["driver_name"]
driver_jar_path = db_config["driver_jar_path"]
db_user = db_config["db_user"]
db_password = db_config["db_password"]
jdbc_url = db_config["jdbc_url"]
OAuth = [str(db_user),str(db_password)]
if not db_user and not db_password:
OAuth = None
#conn to db by jaydebeapi
conn = jaydebeapi.connect(driver_name,
jdbc_url,
OAuth,
driver_jar_path)
@repeat(every(2).seconds)
def create_table():
print("create_table ....")
@repeat(every(20).seconds)
def insert_data():
print("insert_data ....")
@repeat(every(5).seconds)
def dalete_data():
print("dalete_data....")
@repeat(every(6).seconds)
def updata_data():
print("updata_data ....")
if __name__ == '__main__':
while True:
run_pending()

View File

@ -18,6 +18,7 @@ from random import choice
5. 每10分钟从当天的文件中随机找个1个文件删除前100条数据
6. 每6小时从所有的文件中随机删除1个文件
"""
#TODO(MH):目前这些参数是写死的,后续看使用情况,也可以去读配置文件的
# 定义公共的部分
@ -29,8 +30,6 @@ if not data_dir.exists():
data_dir.mkdir()
# 定义文件的信息
def file_info():
file_info_list = []
now = datetime.now()
@ -49,9 +48,7 @@ def file_info():
return (file_info_list)
# 每小时生成一个10M大小的csv文件
# @repeat(every(1).hours) --是基于运行的时间,不是基于系统时间
# @repeat(every(1).hours) TODO(MH):这个是基于运行的时间,不是基于系统时间
def new():
print('new...')
# 创建文件夹

Binary file not shown.

7
etc/test_config.yml Normal file
View File

@ -0,0 +1,7 @@
#数据库配置文件
driver_name: "com.mysql.cj.jdbc.Driver"
driver_jar: "mysql-connector-java-8.0.29.jar"
jdbc_url: "jdbc:mysql://10.10.29.9:3306/"
db_user: "root"
db_password: "Unary@2023"

View File

@ -1,3 +1,4 @@
faker==19.12.0
schedule==1.2.1
PyYAML==6.0.1