提交修改

This commit is contained in:
halliday 2023-11-07 18:01:16 +08:00
parent 48c537f092
commit ce9db1bd1d
4 changed files with 12 additions and 11 deletions

View File

@ -19,14 +19,14 @@ etc_dir = path.parent.parent / "etc"
def mysql_config(): def mysql_config():
mysql_info_dict={} mysql_info_dict={}
mysql_info_dict['driver_name'] = "com.mysql.jdbc.Driver" mysql_info_dict['driver_name'] = "com.mysql.cj.jdbc.Driver"
mysql_info_dict['driver_jar'] = "mysql-connector-java-8.0.29.jar" mysql_info_dict['driver_jar'] = "mysql-connector-java-8.0.29.jar"
driver_jar_path = etc_dir / "driver" / mysql_info_dict['driver_jar'] driver_jar_path = etc_dir / "driver" / mysql_info_dict['driver_jar']
mysql_info_dict['driver_jar_path'] = str(driver_jar_path) mysql_info_dict['driver_jar_path'] = str(driver_jar_path)
#这里要连接到具体的库 #这里要连接到具体的库
mysql_info_dict['jdbc_url'] = "jdbc:mysql://10.10.29.9:3306/test2" mysql_info_dict['jdbc_url'] = "jdbc:mysql://10.10.14.69:3306/sys"
mysql_info_dict['db_user'] = "root" mysql_info_dict['db_user'] = "root"
mysql_info_dict['db_password'] = "Unary@2023" mysql_info_dict['db_password'] = "111111"
#create table sql #create table sql
# now_hours = get_now() # now_hours = get_now()
@ -44,13 +44,13 @@ def mysql_config():
create_sql_string += "`email` varchar(50) DEFAULT NULL," create_sql_string += "`email` varchar(50) DEFAULT NULL,"
create_sql_string += "`job` varchar(50) DEFAULT NULL," create_sql_string += "`job` varchar(50) DEFAULT NULL,"
create_sql_string += "`address` varchar(50) DEFAULT NULL," create_sql_string += "`address` varchar(50) DEFAULT NULL,"
create_sql_string += "`actime_time` timestamp NULL DEFAULT NULL" create_sql_string += "`actime_time` varchar(50) NULL DEFAULT NULL"
create_sql_string += ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;" create_sql_string += ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;"
mysql_info_dict['create_sql_string'] = create_sql_string mysql_info_dict['create_sql_string'] = create_sql_string
# insert into sql # insert into sql
insert_list = [] insert_list = []
data = faker_data.faker_data(lines=2)[1:] data = faker_data.faker_data(lines=200)[1:]
for a in data: for a in data:
#拼接sql #拼接sql
insert_sql_string = "INSERT INTO " + table_name insert_sql_string = "INSERT INTO " + table_name
@ -68,7 +68,7 @@ def mysql_config():
# uptata sql # uptata sql
updata_sql = "UPDATE "+ table_name + " t SET t.job='测试' WHERE t.name like '%' AND sex = 1 AND id = 1 " updata_sql = "UPDATE "+ table_name + " t SET t.job='unary_测试' WHERE t.name like '%' AND sex = 1 AND id = 1 "
mysql_info_dict['updata_sql'] = updata_sql mysql_info_dict['updata_sql'] = updata_sql
return(mysql_info_dict) return(mysql_info_dict)
@ -106,7 +106,7 @@ def oracle_config():
# insert into sql # insert into sql
insert_list = [] insert_list = []
data = faker_data.faker_data(lines=2)[1:] data = faker_data.faker_data(lines=200)[1:]
for a in data: for a in data:
#拼接sql #拼接sql
insert_sql_string = "INSERT INTO " + table_name insert_sql_string = "INSERT INTO " + table_name
@ -124,7 +124,7 @@ def oracle_config():
# uptata sql # uptata sql
updata_sql = "UPDATE "+ table_name + " t SET t.job='测试' WHERE t.name like '%' AND sex = 1 AND id = 1 " updata_sql = "UPDATE "+ table_name + " t SET t.job='unary_测试' WHERE t.name like '%' AND sex = 1 AND id = 1 "
oracle_info_dict['updata_sql'] = updata_sql oracle_info_dict['updata_sql'] = updata_sql
return(oracle_info_dict) return(oracle_info_dict)

View File

@ -19,7 +19,7 @@ from schedule import every, repeat, run_pending
""" """
# 目前支持 MySQL和Oracle两种数据库其他的数据库需要做适配 # 目前支持 MySQL和Oracle两种数据库其他的数据库需要做适配
DBType = "oracle" DBType = "mysql"
#获取连接信息 #获取连接信息

View File

@ -1,6 +1,7 @@
#encoding=utf-8 #encoding=utf-8
import csv import csv
from faker import Faker from faker import Faker
from datetime import datetime
""" """
生成尽可能真实的假数据 生成尽可能真实的假数据
@ -65,7 +66,7 @@ def faker_data(lines=10):
address = f.address()[:-9] + str(f.pyint(min_value=0, max_value=999))+ "" address = f.address()[:-9] + str(f.pyint(min_value=0, max_value=999))+ ""
data.append(address) data.append(address)
#获取时间近3年的 #获取时间近3年的
actime_time = f.date_time_between(start_date="-3y", end_date="now") actime_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
data.append(actime_time) data.append(actime_time)
#将这一行数据添加到datas中 #将这一行数据添加到datas中
datas.append(data) datas.append(data)

View File

@ -56,7 +56,7 @@ def new():
if not finfo[2].exists(): if not finfo[2].exists():
finfo[2].mkdir() finfo[2].mkdir()
# 创建文件 # 创建文件
faker_data.save_data_csv(finfo[4], lines=50000) faker_data.save_data_csv(finfo[4], lines=200000)
# 每2秒插入10条数据 # 每2秒插入10条数据