mirror of https://gitlab.com/pamhyr/pamhyr2
pollutants edit db
parent
37dd4ebaef
commit
1535247e1b
|
|
@ -64,6 +64,7 @@ class HydraulicStructure(SQLSubModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute):
|
def _db_create(cls, execute):
|
||||||
|
|
||||||
execute("""
|
execute("""
|
||||||
CREATE TABLE hydraulic_structures(
|
CREATE TABLE hydraulic_structures(
|
||||||
id INTEGER NOT NULL PRIMARY KEY,
|
id INTEGER NOT NULL PRIMARY KEY,
|
||||||
|
|
@ -138,6 +139,7 @@ class HydraulicStructure(SQLSubModel):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
|
print("save hs unit")
|
||||||
execute(f"DELETE FROM hydraulic_structures WHERE id = {self.id}")
|
execute(f"DELETE FROM hydraulic_structures WHERE id = {self.id}")
|
||||||
|
|
||||||
input_reach_id = -1
|
input_reach_id = -1
|
||||||
|
|
|
||||||
|
|
@ -82,15 +82,18 @@ class OutputKpAdists(SQLSubModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute):
|
def _db_create(cls, execute):
|
||||||
execute("""
|
|
||||||
CREATE TABLE OutputKpAdists(
|
sql = (
|
||||||
id INTEGER NOT NULL PRIMARY KEY,
|
"CREATE TABLE OutputKpAdists(" +
|
||||||
reach INTEGER NOT NULL,
|
"id INTEGER NOT NULL PRIMARY KEY, " +
|
||||||
kp REAL NOT NULL,
|
"reach INTEGER NOT NULL, " +
|
||||||
title TEXT NOT NULL,
|
"kp REAL NOT NULL, " +
|
||||||
FOREIGN KEY(edge) REFERENCES river_reach(id)
|
"title TEXT NOT NULL, " +
|
||||||
)
|
"FOREIGN KEY(reach) REFERENCES river_reach(id)" +
|
||||||
""")
|
")"
|
||||||
|
)
|
||||||
|
|
||||||
|
execute(sql)
|
||||||
|
|
||||||
return cls._create_submodel(execute)
|
return cls._create_submodel(execute)
|
||||||
|
|
||||||
|
|
@ -130,21 +133,14 @@ class OutputKpAdists(SQLSubModel):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
|
|
||||||
print("print output kp unit")
|
|
||||||
print("id : ", self.id)
|
|
||||||
print("reach : ", self._reach)
|
|
||||||
print("kp : ", self._kp)
|
|
||||||
print("title : ", self._title)
|
|
||||||
print("title format : ", self._db_format(self._title))
|
|
||||||
|
|
||||||
execute(f"DELETE FROM OutputKpAdists WHERE id = {self.id}")
|
execute(f"DELETE FROM OutputKpAdists WHERE id = {self.id}")
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"OutputKpAdists(id, reach, kp, title) " +
|
"OutputKpAdists(id, reach, kp, title) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, {self._reach}, " +
|
f"{self.id}, {self._reach}, {self._kp}, " +
|
||||||
f"{self._kp}, '{self._db_format(self._title)}'" +
|
f"'{self._db_format(self._title)}'" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ class OutputKpAdistsList(PamhyrModelList):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
print("save outputkpadists")
|
|
||||||
ok = True
|
ok = True
|
||||||
|
|
||||||
# Delete previous data
|
# Delete previous data
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ class Pollutants(SQLSubModel):
|
||||||
apd REAL NOT NULL,
|
apd REAL NOT NULL,
|
||||||
ac REAL NOT NULL,
|
ac REAL NOT NULL,
|
||||||
bc REAL NOT NULL,
|
bc REAL NOT NULL,
|
||||||
|
pollutant INTEGER NOT NULL,
|
||||||
FOREIGN KEY(pollutant) REFERENCES Pollutants(id)
|
FOREIGN KEY(pollutant) REFERENCES Pollutants(id)
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
@ -126,7 +127,7 @@ class Pollutants(SQLSubModel):
|
||||||
|
|
||||||
if table is not None:
|
if table is not None:
|
||||||
for t in table:
|
for t in table:
|
||||||
new_data.append(t)
|
new_data = t[1:]
|
||||||
|
|
||||||
new_pollutant._data.append(new_data)
|
new_pollutant._data.append(new_data)
|
||||||
|
|
||||||
|
|
@ -136,14 +137,12 @@ class Pollutants(SQLSubModel):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
|
|
||||||
print("save in data base for pollutants")
|
|
||||||
|
|
||||||
execute(f"DELETE FROM Pollutants WHERE id = {self.id}")
|
execute(f"DELETE FROM Pollutants WHERE id = {self.id}")
|
||||||
execute(f"DELETE FROM Pollutants_characteristics WHERE pollutant = {self.id}")
|
execute(f"DELETE FROM Pollutants_characteristics WHERE pollutant = {self.id}")
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"Pollutants(id, name " +
|
"Pollutants(id, name) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, " +
|
f"{self.id}, " +
|
||||||
f"'{self._db_format(self._name)}'" +
|
f"'{self._db_format(self._name)}'" +
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ class PollutantsList(PamhyrModelList):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
print("save pollutantsList")
|
|
||||||
ok = True
|
ok = True
|
||||||
|
|
||||||
# Delete previous data
|
# Delete previous data
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ class EditPolluantWindow(PamhyrWindow):
|
||||||
trad = EditPollutantTranslate()
|
trad = EditPollutantTranslate()
|
||||||
|
|
||||||
name = trad[self._pamhyr_name]
|
name = trad[self._pamhyr_name]
|
||||||
print(name)
|
|
||||||
if self._data is not None:
|
if self._data is not None:
|
||||||
name += (
|
name += (
|
||||||
f" - {study.name} " +
|
f" - {study.name} " +
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue