Use sql batch to optimize

This commit is contained in:
WQY\qiong
2023-03-16 08:30:04 +08:00
parent 1d2ac09c92
commit 04a58bb864
29 changed files with 145 additions and 105 deletions

View File

@@ -222,26 +222,28 @@ def inp_in_reaction(section: list[str]) -> ChangeSet:
return cs
def inp_in_reaction_new(name: str, line: str) -> None:
def inp_in_reaction_new(line: str) -> str:
tokens = line.split()
token0 = tokens[0].upper()
if token0 == 'BULK' or token0 == 'WALL':
pipe = tokens[1]
key = token0.lower()
value = tokens[2]
write(name, f"insert into reactions_pipe_{key} (pipe, value) values ('{pipe}', {value});")
return f"insert into reactions_pipe_{key} (pipe, value) values ('{pipe}', {value});"
elif token0 == 'TANK':
tank = tokens[1]
value = tokens[2]
write(name, f"insert into reactions_tank (tank, value) values ('{tank}', {value});")
return f"insert into reactions_tank (tank, value) values ('{tank}', {value});"
else:
line = line.upper().strip()
for key in get_reaction_schema('').keys():
if line.startswith(key):
value = line.removeprefix(key).strip()
write(name, f"update reactions set value = '{value}' where key = '{key}';")
return f"update reactions set value = '{value}' where key = '{key}';"
return ''
def inp_out_reaction(name: str) -> list[str]: