修改提交
This commit is contained in:
parent
bc06a43441
commit
55c9d80e66
|
@ -87,7 +87,7 @@ def oracle_config():
|
|||
driver_jar_path = etc_dir / "driver" / oracle_info_dict['driver_jar']
|
||||
oracle_info_dict['driver_jar_path'] = str(driver_jar_path)
|
||||
#这里要连接到具体的实例
|
||||
oracle_info_dict['jdbc_url'] = "jdbc:oracle:thin:@" + config['IP'] + ":" + config['PROT'] + "/" + config['DATABASES']
|
||||
oracle_info_dict['jdbc_url'] = "jdbc:oracle:thin:@" + config['IP'] + ":" + config['PROT'] + "/" + config['SERVER']
|
||||
oracle_info_dict['db_user'] = config['DBUSER']
|
||||
oracle_info_dict['db_password'] = config['DBPASSWD']
|
||||
|
||||
|
@ -114,7 +114,7 @@ def oracle_config():
|
|||
data = faker_data.faker_data(lines=config['InsertRows'])[1:]
|
||||
for a in data:
|
||||
#拼接sql
|
||||
insert_sql_string = "INSERT INTO " + table_name
|
||||
insert_sql_string = 'INSERT INTO ' + config['DATABASES'] + '."' + table_name + '" '
|
||||
insert_sql_string += " t (uuid, id, name, mobile, ssn, sex, email, job, address, actime_time) VALUES("
|
||||
str_data = ','.join("'{0}'".format(x) for x in a)
|
||||
insert_sql_string += str_data + ")"
|
||||
|
@ -124,12 +124,12 @@ def oracle_config():
|
|||
oracle_info_dict['insert_list'] = insert_list
|
||||
|
||||
# delete sql
|
||||
del_sql = "delete FROM "+ table_name + " WHERE rownum<=100"
|
||||
del_sql = 'delete FROM "'+ config['DATABASES'] + '."' + table_name + '"WHERE rownum<=100'
|
||||
oracle_info_dict['del_sql'] = del_sql
|
||||
|
||||
|
||||
# uptata sql
|
||||
updata_sql = "UPDATE "+ table_name + " t SET t.job='unary_测试' WHERE t.name like '李%' AND sex = 1 AND id = 1 "
|
||||
updata_sql = "UPDATE "+ config['DATABASES'] + '."' + table_name + '" '+ " t SET t.job='unary_测试' WHERE t.name like '李%' AND sex = 1 AND id = 1 "
|
||||
oracle_info_dict['updata_sql'] = updata_sql
|
||||
|
||||
return(oracle_info_dict)
|
||||
|
|
|
@ -50,7 +50,8 @@ def execute_sql(sql):
|
|||
with conn.cursor() as curs:
|
||||
curs.execute(sql)
|
||||
|
||||
@repeat(every().monday)
|
||||
# 按周创建,这里不采用这种方式,通过插入来触发
|
||||
#@repeat(every().monday)
|
||||
def create_table():
|
||||
print("start create table...")
|
||||
sql_string = db_config["create_sql_string"]
|
||||
|
@ -63,16 +64,18 @@ def create_table():
|
|||
#每秒插入200条数据
|
||||
@repeat(every(2).seconds)
|
||||
def insert_data():
|
||||
create_table()
|
||||
print("insert data ....")
|
||||
#重新获取一下,确保每次的插入的数据都不一样
|
||||
db_config2 = get_db_info()
|
||||
print("insert data ...."+db_config2["jdbc_url"])
|
||||
insert_list = db_config2["insert_list"]
|
||||
#执行插入
|
||||
try:
|
||||
for sql_string in insert_list:
|
||||
execute_sql(sql_string)
|
||||
|
||||
# 出错可能是表不存在,这里触发一下建表
|
||||
except:
|
||||
create_table()
|
||||
|
||||
#每5分钟删除100条数据
|
||||
@repeat(every(5).minutes)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#数据库配置文件
|
||||
|
||||
# 数据库类型,目前仅支持MySQL和Oracle
|
||||
DBType: MySQL
|
||||
DBType: Oracle
|
||||
# 数据库地址
|
||||
IP: "10.10.13.167"
|
||||
PROT: "3306"
|
||||
IP: "10.10.29.41"
|
||||
PROT: "1521"
|
||||
# 数据库用户名
|
||||
DBUSER: "root"
|
||||
DBUSER: "test"
|
||||
# 数据库密码
|
||||
DBPASSWD: "111111"
|
||||
DBPASSWD: "test123"
|
||||
# 库名
|
||||
DATABASES: "test"
|
||||
DATABASES: "TEST"
|
||||
# 服务名-Oracle
|
||||
SERVER: "orcl"
|
||||
# 每秒中插入多少条数据
|
||||
InsertRows: 200
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
PyYAML==6.0.1
|
||||
faker==19.12.0
|
||||
schedule==1.2.1
|
||||
JPype1==1.4.1
|
||||
JayDeBeApi==1.2.3
|
||||
|
||||
|
|
Loading…
Reference in New Issue