mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
DB: Fixes some table fk to prepare update to 0.1.0.
This commit is contained in:
1 parent
16350b4dec
commit
4081f96d68
4 files changed
+79
-34
No files matched your search
@@ -204,6 +204,41 @@ class SQLSubModel(PamhyrID):
|
||||
"""
|
||||
raise NotImplementedMethodeError(cls, cls._db_update)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_node_pid(cls, execute, table, nodes):
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, node FROM {table}"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
node_id = next(it)
|
||||
|
||||
execute(
|
||||
f"UPDATE {table} " +
|
||||
f"SET node = {nodes[node_id]}, " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_reach_pid(cls, execute, table, reachs):
|
||||
els = execute(
|
||||
f"SELECT pamhyr_id, reach FROM {table}"
|
||||
)
|
||||
|
||||
for row in els:
|
||||
it = iter(row)
|
||||
pid = next(it)
|
||||
reach_id = next(it)
|
||||
|
||||
execute(
|
||||
f"UPDATE {table} " +
|
||||
f"SET reach = {reachs[reach_id]}, " +
|
||||
f"WHERE pamhyr_id = {pid}"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_load(cls, execute, data=None):
|
||||
"""Load instance of this class from SQL data base
|
||||
|
||||
Reference in new issue
Block a user