Commit 1535247e authored by Youcef Aouad's avatar Youcef Aouad
Browse files

pollutants edit db

No related merge requests found
Pipeline #55789 passed with stages
in 59 seconds
Showing with 19 additions and 25 deletions
+19 -25
......@@ -64,6 +64,7 @@ class HydraulicStructure(SQLSubModel):
@classmethod
def _db_create(cls, execute):
execute("""
CREATE TABLE hydraulic_structures(
id INTEGER NOT NULL PRIMARY KEY,
......@@ -138,6 +139,7 @@ class HydraulicStructure(SQLSubModel):
return new
def _db_save(self, execute, data=None):
print("save hs unit")
execute(f"DELETE FROM hydraulic_structures WHERE id = {self.id}")
input_reach_id = -1
......
......@@ -82,15 +82,18 @@ class OutputKpAdists(SQLSubModel):
@classmethod
def _db_create(cls, execute):
execute("""
CREATE TABLE OutputKpAdists(
id INTEGER NOT NULL PRIMARY KEY,
reach INTEGER NOT NULL,
kp REAL NOT NULL,
title TEXT NOT NULL,
FOREIGN KEY(edge) REFERENCES river_reach(id)
)
""")
sql = (
"CREATE TABLE OutputKpAdists(" +
"id INTEGER NOT NULL PRIMARY KEY, " +
"reach INTEGER NOT NULL, " +
"kp REAL NOT NULL, " +
"title TEXT NOT NULL, " +
"FOREIGN KEY(reach) REFERENCES river_reach(id)" +
")"
)
execute(sql)
return cls._create_submodel(execute)
......@@ -130,21 +133,14 @@ class OutputKpAdists(SQLSubModel):
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}")
sql = (
"INSERT INTO " +
"OutputKpAdists(id, reach, kp, title) " +
"VALUES (" +
f"{self.id}, {self._reach}, " +
f"{self._kp}, '{self._db_format(self._title)}'" +
f"{self.id}, {self._reach}, {self._kp}, " +
f"'{self._db_format(self._title)}'" +
")"
)
......
......@@ -35,7 +35,6 @@ class OutputKpAdistsList(PamhyrModelList):
return new
def _db_save(self, execute, data=None):
print("save outputkpadists")
ok = True
# Delete previous data
......
......@@ -86,6 +86,7 @@ class Pollutants(SQLSubModel):
apd REAL NOT NULL,
ac REAL NOT NULL,
bc REAL NOT NULL,
pollutant INTEGER NOT NULL,
FOREIGN KEY(pollutant) REFERENCES Pollutants(id)
)
""")
......@@ -126,7 +127,7 @@ class Pollutants(SQLSubModel):
if table is not None:
for t in table:
new_data.append(t)
new_data = t[1:]
new_pollutant._data.append(new_data)
......@@ -136,14 +137,12 @@ class Pollutants(SQLSubModel):
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_characteristics WHERE pollutant = {self.id}")
sql = (
"INSERT INTO " +
"Pollutants(id, name " +
"Pollutants(id, name) " +
"VALUES (" +
f"{self.id}, " +
f"'{self._db_format(self._name)}'" +
......
......@@ -35,7 +35,6 @@ class PollutantsList(PamhyrModelList):
return new
def _db_save(self, execute, data=None):
print("save pollutantsList")
ok = True
# Delete previous data
......
......@@ -57,7 +57,6 @@ class EditPolluantWindow(PamhyrWindow):
trad = EditPollutantTranslate()
name = trad[self._pamhyr_name]
print(name)
if self._data is not None:
name += (
f" - {study.name} " +
......
No preview for this file type
File added
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment