mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
pollutants edit db
This commit is contained in:
1 parent
37dd4ebaef
commit
1535247e1b
9 files changed
+19
-25
No files matched your search
@@ -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} " +
|
||||
|
||||
Reference in new issue
Block a user