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