Adists: Prepare for scenarios update (commit code is not working).

scenarios
Pierre-Antoine 2025-08-12 15:36:19 +02:00
parent c43a26870e
commit 37cf42c524
12 changed files with 362 additions and 122 deletions

View File

@ -52,30 +52,41 @@ class BoundaryConditionAdisTS(SQLSubModel):
self._types = [self.time_convert, float] self._types = [self.time_convert, float]
@classmethod @classmethod
def _db_create(cls, execute): def _db_create(cls, execute, ext=""):
execute(""" cls._db_create_bca(execute, ext)
CREATE TABLE boundary_condition_adists( cls._db_create_bca_data(execute, ext)
id INTEGER NOT NULL PRIMARY KEY,
return cls._create_submodel(execute)
@classmethod
def _db_create_bca(cls, execute, ext=""):
execute(f"""
CREATE TABLE boundary_condition_adists{ext}(
{cls.create_db_add_pamhyr_id()},
pollutant INTEGER NOT NULL, pollutant INTEGER NOT NULL,
type TEXT NOT NULL, type TEXT NOT NULL,
node INTEGER, node INTEGER,
FOREIGN KEY(pollutant) REFERENCES Pollutants(id), {Scenario.create_db_add_scenario()},
FOREIGN KEY(node) REFERENCES river_node(id) {Scenario.create_db_add_scenario_fk()},
FOREIGN KEY(pollutant) REFERENCES Pollutants(pamhyr_id),
FOREIGN KEY(node) REFERENCES river_node(pamhyr_id)
) )
""") """)
execute(""" @classmethod
CREATE TABLE boundary_condition_data_adists( def _db_create_bca_data(cls, execute, ext=""):
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, execute(f"""
CREATE TABLE boundary_condition_data_adists{ext}(
{cls.create_db_add_pamhyr_id()},
data0 TEXT NOT NULL, data0 TEXT NOT NULL,
data1 TEXT NOT NULL, data1 TEXT NOT NULL,
bc INTEGER, bca INTEGER,
FOREIGN KEY(bc) REFERENCES boundary_condition_adists(id) {Scenario.create_db_add_scenario()},
{Scenario.create_db_add_scenario_fk()},
FOREIGN KEY(bca) REFERENCES boundary_condition_adists(pamhyr_id)
) )
""") """)
return cls._create_submodel(execute)
@classmethod @classmethod
def _db_update(cls, execute, version, data=None): def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".") major, minor, release = version.strip().split(".")
@ -83,8 +94,55 @@ class BoundaryConditionAdisTS(SQLSubModel):
if int(release) < 7: if int(release) < 7:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) < 2:
cls._db_update_to_0_2_0(execute, data)
return True return True
@classmethod
def _db_update_to_0_2_0(cls, execute, data):
table = "boundary_condition_adists"
nodes = data['id2pid']['river_node']
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_bca(execute, ext="_tmp")
execute(
f"INSERT INTO {table}_tmp " +
"(pamhyr_id, pollutant, type, node, scenario) " +
"SELECT pamhyr_id, pollutant, type, node, scenario " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
cls._db_update_to_0_2_0_set_node_pid(execute, table, reachs)
@classmethod
def _db_update_to_0_2_0_data(cls, execute, data):
table = "boundary_condition_data_adists"
reachs = data['id2pid']['river_reach']
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_bca_data(execute, ext="_tmp")
execute(
f"INSERT INTO {table}_tmp " +
"(pamhyr_id, data0, data1, bca, scenario) " +
"SELECT pamhyr_id, data0, data1, bc, scenario) " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -45,14 +45,20 @@ class BoundaryConditionsAdisTSList(PamhyrModelList):
return new return new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):
execute("DELETE FROM boundary_condition_adists") execute(
execute("DELETE FROM boundary_condition_data_adists") "DELETE FROM boundary_condition_adists" +
f"WHERE scenario = {self._status.scenario_id}"
)
execute(
"DELETE FROM boundary_condition_data_adists" +
f"WHERE scenario = {self._status.scenario_id}"
)
if data is None: if data is None:
data = {} data = {}
for bc in self._lst: for bca in self._lst:
bc._db_save(execute, data=data) bca._db_save(execute, data=data)
return True return True

View File

@ -50,15 +50,17 @@ class D90AdisTS(SQLSubModel):
self._data = [] self._data = []
@classmethod @classmethod
def _db_create(cls, execute): def _db_create(cls, execute, ext=""):
execute(""" execute(f"""
CREATE TABLE d90_adists( CREATE TABLE d90_adists{ext}(
id INTEGER NOT NULL PRIMARY KEY, {cls.create_db_add_pamhyr_id()},
name TEXT NOT NULL, name TEXT NOT NULL,
d90 REAL NOT NULL, d90 REAL NOT NULL,
enabled BOOLEAN NOT NULL enabled BOOLEAN NOT NULL,
) {Scenario.create_db_add_scenario()},
""") {Scenario.create_db_add_scenario_fk()}
)
""")
return cls._create_submodel(execute) return cls._create_submodel(execute)
@ -69,8 +71,30 @@ class D90AdisTS(SQLSubModel):
if int(release) < 6: if int(release) < 6:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) < 2:
cls._db_update_to_0_2_0(execute, data)
return True return True
@classmethod
def _db_update_to_0_2_0(cls, execute, data):
table = "d90_adists"
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_lca(execute, ext="_tmp")
execute(
f"INSERT INTO {table}_tmp " +
"(pamhyr_id, name, d90, enabled, scenario) " +
"SELECT pamhyr_id, name, d90, enabled, scenario " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -42,7 +42,10 @@ class D90AdisTSList(PamhyrModelList):
return new return new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):
execute("DELETE FROM d90_adists") execute(
"DELETE FROM d90_adists" +
f"WHERE scenario = {self._status.scenario_id}"
)
if data is None: if data is None:
data = {} data = {}

View File

@ -52,21 +52,23 @@ class D90AdisTSSpec(SQLSubModel):
D90AdisTSSpec._id_cnt = max(D90AdisTSSpec._id_cnt + 1, self.id) D90AdisTSSpec._id_cnt = max(D90AdisTSSpec._id_cnt + 1, self.id)
@classmethod @classmethod
def _db_create(cls, execute): def _db_create(cls, execute, ext=""):
execute(""" execute(f"""
CREATE TABLE d90_spec( CREATE TABLE d90_adists_spec{ext}(
id INTEGER NOT NULL PRIMARY KEY, {cls.create_db_add_pamhyr_id()},
d90_default INTEGER NOT NULL, d90_default INTEGER NOT NULL,
name TEXT NOT NULL, name TEXT NOT NULL,
reach INTEGER NOT NULL, reach INTEGER NOT NULL,
start_rk REAL NOT NULL, start_rk REAL NOT NULL,
end_rk REAL NOT NULL, end_rk REAL NOT NULL,
d90 REAL NOT NULL, d90 REAL NOT NULL,
enabled BOOLEAN NOT NULL, enabled BOOLEAN NOT NULL,
FOREIGN KEY(d90_default) REFERENCES d90_adists(id), {Scenario.create_db_add_scenario()},
FOREIGN KEY(reach) REFERENCES river_reach(id) {Scenario.create_db_add_scenario_fk()},
) FOREIGN KEY(d90_default) REFERENCES d90_adists(pamhyr_id),
""") FOREIGN KEY(reach) REFERENCES river_reach(pamhyr_id)
)
""")
return cls._create_submodel(execute) return cls._create_submodel(execute)
@ -77,8 +79,31 @@ class D90AdisTSSpec(SQLSubModel):
if int(release) < 6: if int(release) < 6:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) < 2:
cls._db_update_to_0_2_0(execute, data)
return True return True
@classmethod
def _db_update_to_0_2_0(cls, execute, data):
table = "d90_spec"
table_new = "d90_adists_spec"
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_lca(execute, ext="_tmp")
execute(
f"INSERT INTO {table_new}_tmp " +
"(pamhyr_id, name, d90, enabled, scenario) " +
"SELECT pamhyr_id, name, d90, enabled, scenario " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -53,18 +53,20 @@ class DIFAdisTS(SQLSubModel):
self._data = [] self._data = []
@classmethod @classmethod
def _db_create(cls, execute): def _db_create(cls, execute, ext=""):
execute(""" execute(f"""
CREATE TABLE dif_adists( CREATE TABLE dif_adists{ext}(
id INTEGER NOT NULL PRIMARY KEY, {cls.create_db_add_pamhyr_id()},
name TEXT NOT NULL, name TEXT NOT NULL,
method TEXT NOT NULL, method TEXT NOT NULL,
dif REAL NOT NULL, dif REAL NOT NULL,
b REAL, b REAL,
c REAL, c REAL,
enabled BOOLEAN NOT NULL enabled BOOLEAN NOT NULL,
) {Scenario.create_db_add_scenario()},
""") {Scenario.create_db_add_scenario_fk()}
)
""")
return cls._create_submodel(execute) return cls._create_submodel(execute)
@ -75,8 +77,30 @@ class DIFAdisTS(SQLSubModel):
if int(release) < 6: if int(release) < 6:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) < 2:
cls._db_update_to_0_2_0(execute, data)
return True return True
@classmethod
def _db_update_to_0_2_0(cls, execute, data):
table = "dif_adists"
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_lca(execute, ext="_tmp")
execute(
f"INSERT INTO {table}_tmp " +
"(pamhyr_id, name, method, dif, b, c, enabled, scenario) " +
"SELECT pamhyr_id, name, method, dif, b, c, enabled, scenario " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []
@ -137,7 +161,7 @@ class DIFAdisTS(SQLSubModel):
sql = ( sql = (
"INSERT INTO " + "INSERT INTO " +
"dif_adists(" + "dif_adists(" +
"id, name, method, dif, b, c, enabled" + "pamhyr_id, name, method, dif, b, c, enabled" +
") " + ") " +
"VALUES (" + "VALUES (" +
f"{self.id}, '{self._db_format(self._name)}', " + f"{self.id}, '{self._db_format(self._name)}', " +
@ -150,7 +174,7 @@ class DIFAdisTS(SQLSubModel):
data['dif_default_id'] = self.id data['dif_default_id'] = self.id
execute( execute(
"DELETE FROM dif_spec " + "DELETE FROM dif_adists_spec " +
f"WHERE dif_default = {self.id}" f"WHERE dif_default = {self.id}"
) )

View File

@ -42,7 +42,10 @@ class DIFAdisTSList(PamhyrModelList):
return new return new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):
execute("DELETE FROM dif_adists") execute(
"DELETE FROM dif_adists" +
f"WHERE scenario = {self._status.scenario_id}"
)
if data is None: if data is None:
data = {} data = {}

View File

@ -55,22 +55,24 @@ class DIFAdisTSSpec(SQLSubModel):
@classmethod @classmethod
def _db_create(cls, execute): def _db_create(cls, execute):
execute(""" execute(f"""
CREATE TABLE dif_spec( CREATE TABLE dif_adists_spec{ext}(
id INTEGER NOT NULL PRIMARY KEY, {cls.create_db_add_pamhyr_id()},
dif_default INTEGER NOT NULL, dif_default INTEGER NOT NULL,
method TEXT NOT NULL, method TEXT NOT NULL,
reach INTEGER NOT NULL, reach INTEGER NOT NULL,
start_rk REAL NOT NULL, start_rk REAL NOT NULL,
end_rk REAL NOT NULL, end_rk REAL NOT NULL,
dif REAL NOT NULL, dif REAL NOT NULL,
b REAL, b REAL,
c REAL, c REAL,
enabled BOOLEAN NOT NULL, enabled BOOLEAN NOT NULL,
FOREIGN KEY(dif_default) REFERENCES dif_adists(id), {Scenario.create_db_add_scenario()},
FOREIGN KEY(reach) REFERENCES river_reach(id) {Scenario.create_db_add_scenario_fk()},
) FOREIGN KEY(dif_default) REFERENCES dif_adists(id),
""") FOREIGN KEY(reach) REFERENCES river_reach(id)
)
""")
return cls._create_submodel(execute) return cls._create_submodel(execute)
@ -81,8 +83,34 @@ class DIFAdisTSSpec(SQLSubModel):
if int(release) < 6: if int(release) < 6:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) < 2:
cls._db_update_to_0_2_0(execute, data)
return True return True
@classmethod
def _db_update_to_0_2_0(cls, execute, data):
table = "dif_spec"
table_new = "dif_adists_spec"
reachs = data['id2pid']['river_reach']
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_lca(execute, ext="_tmp")
execute(
f"INSERT INTO {table_new}_tmp " +
"(pamhyr_id, pollutant, reach, begin_rk, end_rk, scenario) " +
"SELECT pamhyr_id, pollutant, edge, begin_rk, end_rk, scenario " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -55,20 +55,22 @@ class InitialConditionsAdisTS(SQLSubModel):
self._data = [] self._data = []
@classmethod @classmethod
def _db_create(cls, execute): def _db_create(cls, execute, ext=""):
execute(""" execute(f"""
CREATE TABLE initial_conditions_adists( CREATE TABLE initial_conditions_adists{ext}(
id INTEGER NOT NULL PRIMARY KEY, {cls.create_db_add_pamhyr_id()},
pollutant INTEGER NOT NULL, pollutant INTEGER NOT NULL,
name TEXT NOT NULL, name TEXT NOT NULL,
concentration REAL NOT NULL, concentration REAL NOT NULL,
eg REAL NOT NULL, eg REAL NOT NULL,
em REAL NOT NULL, em REAL NOT NULL,
ed REAL NOT NULL, ed REAL NOT NULL,
enabled BOOLEAN NOT NULL, enabled BOOLEAN NOT NULL,
FOREIGN KEY(pollutant) REFERENCES Pollutants(id) {Scenario.create_db_add_scenario()},
) {Scenario.create_db_add_scenario_fk()},
""") FOREIGN KEY(pollutant) REFERENCES Pollutants(pamhyr_id)
)
""")
return cls._create_submodel(execute) return cls._create_submodel(execute)
@ -79,8 +81,34 @@ class InitialConditionsAdisTS(SQLSubModel):
if int(release) < 6: if int(release) < 6:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) < 2:
cls._db_update_to_0_2_0(execute, data)
return True return True
@classmethod
def _db_update_to_0_2_0(cls, execute, data):
table = "initial_conditions_adists"
reachs = data['id2pid']['river_reach']
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_lca(execute, ext="_tmp")
execute(
f"INSERT INTO {table}_tmp " +
"(pamhyr_id, pollutant, reach, begin_rk, end_rk, scenario) " +
"SELECT pamhyr_id, pollutant, edge, begin_rk, end_rk, scenario) " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -43,7 +43,10 @@ class InitialConditionsAdisTSList(PamhyrModelList):
return new return new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):
execute("DELETE FROM initial_conditions_adists") execute(
"DELETE FROM initial_conditions_adists" +
f"WHERE scenario = {self._status.scenario_id}"
)
if data is None: if data is None:
data = {} data = {}

View File

@ -56,25 +56,28 @@ class ICAdisTSSpec(SQLSubModel):
ICAdisTSSpec._id_cnt = max(ICAdisTSSpec._id_cnt + 1, self.id) ICAdisTSSpec._id_cnt = max(ICAdisTSSpec._id_cnt + 1, self.id)
@classmethod @classmethod
def _db_create(cls, execute): def _db_create(cls, execute, ext=""):
execute(""" execute(f"""
CREATE TABLE initial_conditions_spec( CREATE TABLE initial_conditions_spec{ext}(
id INTEGER NOT NULL PRIMARY KEY, {cls.create_db_add_pamhyr_id()},
ic_default INTEGER NOT NULL, ic_default INTEGER NOT NULL,
name TEXT NOT NULL, name TEXT NOT NULL,
reach INTEGER NOT NULL, reach INTEGER NOT NULL,
start_rk REAL NOT NULL, start_rk REAL NOT NULL,
end_rk REAL NOT NULL, end_rk REAL NOT NULL,
concentration REAL NOT NULL, concentration REAL NOT NULL,
eg REAL NOT NULL, eg REAL NOT NULL,
em REAL NOT NULL, em REAL NOT NULL,
ed REAL NOT NULL, ed REAL NOT NULL,
rate REAL NOT NULL, rate REAL NOT NULL,
enabled BOOLEAN NOT NULL, enabled BOOLEAN NOT NULL,
FOREIGN KEY(ic_default) REFERENCES initial_conditions_adists(id), {Scenario.create_db_add_scenario()},
FOREIGN KEY(reach) REFERENCES river_reach(id) {Scenario.create_db_add_scenario_fk()},
) FOREIGN KEY(ic_default)
""") REFERENCES initial_conditions_adists(pamhyr_id),
FOREIGN KEY(reach) REFERENCES river_reach(pamhyr_id)
)
""")
return cls._create_submodel(execute) return cls._create_submodel(execute)
@ -85,8 +88,35 @@ class ICAdisTSSpec(SQLSubModel):
if int(release) < 6: if int(release) < 6:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) < 2:
cls._db_update_to_0_2_0(execute, data)
return True return True
@classmethod
def _db_update_to_0_2_0(cls, execute, data):
table = "initial_conditions_spec"
reachs = data['id2pid']['river_reach']
cls.update_db_add_pamhyr_id(execute, table, data)
Scenario.update_db_add_scenario(execute, table)
cls._db_create_lca(execute, ext="_tmp")
execute(
f"INSERT INTO {table}_tmp " +
"(pamhyr_id, ic_default, name, reach, start_rk, end_rk, " +
"concentration, eg, em, ed, rate, enabled, scenario) " +
"SELECT pamhyr_id, ic_default, name, reach, start_rk, end_rk, " +
"concentration, eg, em, ed, rate, enabled, scenario " +
f"FROM {table}"
)
execute(f"DROP TABLE {table}")
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []

View File

@ -96,9 +96,8 @@ class LateralContributionAdisTS(SQLSubModel):
if int(release) < 7: if int(release) < 7:
cls._db_create(execute) cls._db_create(execute)
if major == "0" and int(minor) <= 2: if major == "0" and int(minor) < 2:
if int(release) <= 0: cls._db_update_to_0_2_0(execute, data)
cls._db_update_to_0_2_0(execute, data)
return True return True
@ -115,7 +114,7 @@ class LateralContributionAdisTS(SQLSubModel):
execute( execute(
f"INSERT INTO {table}_tmp " + f"INSERT INTO {table}_tmp " +
"(pamhyr_id, pollutant, reach, begin_rk, end_rk, scenario) " + "(pamhyr_id, pollutant, reach, begin_rk, end_rk, scenario) " +
"SELECT pamhyr_id, pollutant, edge, begin_rk, end_rk, scenario) " + "SELECT pamhyr_id, pollutant, edge, begin_rk, end_rk, scenario " +
f"FROM {table}" f"FROM {table}"
) )
@ -124,7 +123,6 @@ class LateralContributionAdisTS(SQLSubModel):
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs) cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
@classmethod @classmethod
def _db_update_to_0_2_0_data(cls, execute, data): def _db_update_to_0_2_0_data(cls, execute, data):
table = "lateral_contribution_data_adists" table = "lateral_contribution_data_adists"
@ -147,43 +145,53 @@ class LateralContributionAdisTS(SQLSubModel):
cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs) cls._db_update_to_0_2_0_set_reach_pid(execute, table, reachs)
@classmethod @classmethod
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = [] new = []
scenario = data["scenario"]
loaded = data['loaded_pid']
table = execute( table = execute(
"SELECT id, pollutant, edge, begin_rk, end_rk " + "SELECT id, pollutant, edge, begin_rk, end_rk " +
"FROM lateral_contribution_adists" "FROM lateral_contribution_adists" +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
) )
if table is not None: if table is not None:
for row in table: for row in table:
lc = cls( lca = cls(
id=row[0], id=row[0],
pollutant=row[1], pollutant=row[1],
status=data['status'] status=data['status']
) )
lc.edge = row[2] lca.edge = row[2]
lc.begin_rk = row[3] lca.begin_rk = row[3]
lc.end_rk = row[4] lca.end_rk = row[4]
values = execute( values = execute(
"SELECT data0," + "SELECT data0," +
" data1 FROM lateral_contribution_data_adists " + " data1 FROM lateral_contribution_data_adists " +
f"WHERE lc = '{lc.id}'" f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
f"AND lca = '{lca.id}'"
) )
# Write data # Write data
for v in values: for v in values:
data0 = lc._types[0](v[0]) data0 = lca._types[0](v[0])
data1 = lc._types[1](v[1]) data1 = lca._types[1](v[1])
# Replace data at pos ind # Replace data at pos ind
lc._data.append((data0, data1)) lca._data.append((data0, data1))
new.append(lc) new.append(lc)
data["scenario"] = scenario.parent
new += cls._db_load(execute, data)
data["scenario"] = scenario
return new return new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):