DB: Some fixes for db update 0.1.0.

scenarios
Pierre-Antoine Rouby 2024-08-07 11:11:32 +02:00
parent 74c61262b7
commit c7b5b40eda
5 changed files with 12 additions and 18 deletions

View File

@ -85,7 +85,7 @@ class Data(SQLSubModel):
cls._db_create(execute, ext="_tmp") cls._db_create(execute, ext="_tmp")
execute( execute(
f"INSERT INTO {table} " + f"INSERT INTO {table}_tmp " +
"(pamhyr_id, ind, data0, data1, bc, scenario) " + "(pamhyr_id, ind, data0, data1, bc, scenario) " +
"SELECT pamhyr_id, ind, data0, data1, bc, scenario " + "SELECT pamhyr_id, ind, data0, data1, bc, scenario " +
f"FROM {table}" f"FROM {table}"
@ -196,6 +196,9 @@ class BoundaryCondition(SQLSubModel):
) )
""") """)
if ext == "_tmp":
return True
return cls._create_submodel(execute) return cls._create_submodel(execute)
@classmethod @classmethod
@ -278,6 +281,8 @@ class BoundaryCondition(SQLSubModel):
data["bc"] = bc data["bc"] = bc
bc._data = Data._db_load(execute, data=data) bc._data = Data._db_load(execute, data=data)
new.append(bc)
return new return new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):

View File

@ -50,12 +50,10 @@ class FrictionList(PamhyrModelList):
def _db_load(cls, execute, data=None): def _db_load(cls, execute, data=None):
new = cls(status=data['status']) new = cls(status=data['status'])
ilst = Friction._db_load( new._lst = Friction._db_load(
execute, data execute, data
) )
new._lst = list(map(lambda x: x[1], sorted(ilst)))
return new return new
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):

View File

@ -20,7 +20,8 @@ from Model.Except import NotImplementedMethodeError
class Point(object): class Point(object):
def __init__(self, name: str = "", profile=None, status=None): def __init__(self, id:int = -1, name: str = "",
profile=None, status=None):
super(Point, self).__init__() super(Point, self).__init__()
self._status = status self._status = status

View File

@ -57,17 +57,7 @@ class Profile(object):
return len(self.points) return len(self.points)
def _get_points_list(self): def _get_points_list(self):
# Points list generator is type (int, Point) with the first return list(self._points)
# element the index of the Point in list
return list(
map(
lambda p: p[1],
sorted(
self._points,
key=lambda p: p[0]
)
)
)
@property @property
def points(self): def points(self):

View File

@ -102,9 +102,9 @@ class Data(SQLSubModel):
execute( execute(
f"INSERT INTO {table}_tmp " + f"INSERT INTO {table}_tmp " +
"(pamhyr_id, name, comment, reach, rk, " + "(pamhyr_id, ind, name, comment, reach, rk, " +
"discharge, height, scenario) " + "discharge, height, scenario) " +
"SELECT pamhyr_id, name, comment, reach, rk, " + "SELECT pamhyr_id, ind, name, comment, reach, rk, " +
"discharge, height, scenario " + "discharge, height, scenario " +
f"FROM {table}" f"FROM {table}"
) )