mirror of https://gitlab.com/pamhyr/pamhyr2
SQL: Minor change.
parent
911e0c7e17
commit
96d03ee41a
|
|
@ -169,7 +169,7 @@ class Data(SQLSubModel):
|
|||
|
||||
def _update_from_discharge(self):
|
||||
min = self._update_get_min()
|
||||
print("TODO")
|
||||
# print("TODO")
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if key == "name":
|
||||
|
|
|
|||
|
|
@ -170,6 +170,8 @@ class RiverReach(Edge, SQLSubModel):
|
|||
if data is None:
|
||||
data = {}
|
||||
|
||||
data["reach"] = self
|
||||
|
||||
objs = [self._reach, self._sections]
|
||||
return self._save_submodel(execute, objs, data)
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,11 @@ class Section(SQLSubModel):
|
|||
|
||||
for row in table:
|
||||
ind = row[0]
|
||||
# Get stricklers
|
||||
bs = next(filter(lambda s: s.id == row[3], stricklers))
|
||||
es = next(filter(lambda s: s.id == row[4], stricklers))
|
||||
|
||||
# Create section
|
||||
sec = cls(status = status)
|
||||
sec.edge = reach
|
||||
sec.begin_kp = row[1]
|
||||
|
|
@ -74,7 +76,7 @@ class Section(SQLSubModel):
|
|||
def _sql_save(self, execute, data = None):
|
||||
ind = data["ind"]
|
||||
execute(
|
||||
"INSERT OR REPLACE INTO " +
|
||||
"INSERT INTO " +
|
||||
"section(ind, begin_kp, end_kp, reach, begin_strickler, end_strickler) " +
|
||||
"VALUES (" +
|
||||
f"{ind}, {self._begin_kp}, {self._end_kp}, " +
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ class SectionList(SQLSubModel):
|
|||
return new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
reach = data["reach"]
|
||||
execute(f"DELETE FROM section WHERE reach = {reach.id}")
|
||||
|
||||
ok = True
|
||||
ind = 0
|
||||
for section in self._sections:
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ class SQL(object):
|
|||
|
||||
@timer
|
||||
def execute(self, cmd, fetch_one = True, commit = False):
|
||||
print(f"[SQL] {cmd}")
|
||||
# print(f"[SQL] {cmd}")
|
||||
res = self._cur.execute(cmd)
|
||||
|
||||
if commit:
|
||||
|
|
|
|||
Loading…
Reference in New Issue