|
@@ -3,7 +3,7 @@ import kbc_alt
|
|
|
|
|
|
# ----- Record_main(DB record as a class) -----
|
|
|
class RM():
|
|
|
- def __init__(self, type:str="", name:str="", dscrp:str="", creator:str="", createdTime:str="datetime('now')", relatedBoard:str="", relatedClass:str="", state:int=-10) -> None:
|
|
|
+ def __init__(self, type:str="", name:str="", dscrp:str="", creator:str="", createdTime:str="datetime('now')", relatedBoard:str="", relatedClass:str="", statement:int=-10) -> None:
|
|
|
self.id = "null"
|
|
|
self.type = type
|
|
|
self.name = name
|
|
@@ -12,39 +12,35 @@ class RM():
|
|
|
self.createdTime = createdTime
|
|
|
self.relatedBoard = relatedBoard
|
|
|
self.relatedClass = relatedClass
|
|
|
- self.state = state
|
|
|
+ self.statement = statement
|
|
|
|
|
|
|
|
|
def select(self, selectColumn:str="name"):
|
|
|
- return "SELECT {sc} FROM compact_main WHERE type='{s.type}' AND name='{s.name}' AND realatedBoard='{s.relatedBoard}' AND relatedClass='{s.relatedClass}' AND state={s.state};".format(sc=selectColumn, s=self)
|
|
|
+ return "SELECT {sc} FROM compact_main WHERE type={s.type} AND name='{s.name}' AND realatedBoard='{s.relatedBoard}' AND relatedClass='{s.relatedClass}' AND state{s.statement};".format(sc=selectColumn, s=self)
|
|
|
|
|
|
|
|
|
def add(self):
|
|
|
- return "INSERT INTO compact_main VALUES({a.id}, '{a.type}', '{a.name}', '{a.dscrp}', '{a.creator}', '{a.createdTime}', '{a.relatedBoard}', '{a.relatedClass}', {a.state});".format(a=self)
|
|
|
+ return "INSERT INTO compact_main VALUES({a.id}, {a.type}, '{a.name}', '{a.dscrp}', '{a.creator}', '{a.createdTime}', '{a.relatedBoard}', '{a.relatedClass}', {a.statement});".format(a=self)
|
|
|
|
|
|
|
|
|
- def delete(self): # 1. withstate:int=10? 2. withStatement >= or > or <?
|
|
|
- return "UPDATE compact_main SET state=-10 WHERE type='{d.type}' AND name='{d.name}' AND relatedBoard='{d.relatedBoard}' AND relatedClass='{d.relatedClass}' AND state={d.state};".format(d=self)
|
|
|
+ def delete(self):
|
|
|
+ return "UPDATE compact_main SET state=-10 WHERE type={d.type} AND name='{d.name}' AND relatedBoard='{d.relatedBoard}' AND relatedClass='{d.relatedClass}' AND state{d.statement};".format(d=self)
|
|
|
|
|
|
|
|
|
def edit(self, editColumn:str="", editValue:str=""):
|
|
|
- return "UPDATE compact_main SET {ec}='{ev}' WHERE type='{e.type}' AND name='{e.name}' AND relatedBoard='{e.relatedBoard}' AND relatedClass='{e.relatedClass}' AND state={e.state};".format(ec=editColumn, ev=editValue, e=self)
|
|
|
+ return "UPDATE compact_main SET {ec}='{ev}' WHERE type={e.type} AND name='{e.name}' AND relatedBoard='{e.relatedBoard}' AND relatedClass='{e.relatedClass}' AND state{e.statement};".format(ec=editColumn, ev=editValue, e=self)
|
|
|
|
|
|
|
|
|
- def edit_state(self, editValue:int=-10):
|
|
|
- return "UPDATE compact_main SET state={ev} WHERE type='{e.type}' AND name='{e.name}' AND relatedBoard='{e.relatedBoard}' AND relatedClass='{e.relatedClass}' AND state={e.state};".format(ev=editValue, e=self)
|
|
|
-
|
|
|
-
|
|
|
def move(self, moveColumn:str="", moveValue:str=""):
|
|
|
- return "UPDATE compact_main SET {mc}='{mv}' WHERE type='{m.type}' AND name='{m.name}' AND relatedBoard='{m.relatedBoard}' AND relatedClass='{m.relatedClass}' AND state={m.state};".format(mc=moveColumn, mv=moveValue, m=self)
|
|
|
+ return "UPDATE compact_main SET {mc}='{mv}' WHERE type={m.type} AND name='{m.name}' AND relatedBoard='{m.relatedBoard}' AND relatedClass='{m.relatedClass}' AND state{m.statement};".format(mc=moveColumn, mv=moveValue, m=self)
|
|
|
|
|
|
|
|
|
def back(self, selectColumn:str="name"):
|
|
|
- return "SELECT {sc} FROM compact_main WHERE type='{s.type}' AND name='{s.name}' AND realatedBoard='{s.relatedBoard}' AND relatedClass='{s.relatedClass}' AND state={s.state};".format(sc=selectColumn, s=self)
|
|
|
+ return "SELECT {sc} FROM compact_main WHERE type={s.type} AND name='{s.name}' AND realatedBoard='{s.relatedBoard}' AND relatedClass='{s.relatedClass}' AND state{s.statement};".format(sc=selectColumn, s=self)
|
|
|
|
|
|
|
|
|
def export(self, selectColumn:str="name"):
|
|
|
- return "SELECT {sc} FROM compact_main WHERE type='{s.type}' AND name='{s.name}' AND realatedBoard='{s.relatedBoard}' AND relatedClass='{s.relatedClass}' AND state={s.state};".format(sc=selectColumn, s=self)
|
|
|
+ return "SELECT {sc} FROM compact_main WHERE type={s.type} AND name='{s.name}' AND realatedBoard='{s.relatedBoard}' AND relatedClass='{s.relatedClass}' AND state{s.statement};".format(sc=selectColumn, s=self)
|
|
|
|
|
|
|
|
|
def get_style():
|
|
@@ -78,7 +74,7 @@ oc = {
|
|
|
"cp":[], # CurrentPath
|
|
|
"pp":[], # PreviousPath
|
|
|
|
|
|
- "next_move":"",
|
|
|
+ "steps":[],
|
|
|
|
|
|
"tp":[], # TargetPath
|
|
|
"tp_in":[], # ~ after command parameter "in"(&& before command parameter "to")
|
|
@@ -91,22 +87,7 @@ oc = {
|
|
|
|
|
|
|
|
|
# ----- Execute Methods -----
|
|
|
-def exec(dbPath:str="", sqls:str=""):
|
|
|
- if dbPath != "" and sqls != "":
|
|
|
- try:
|
|
|
- con = sqlite3.connect(dbPath)
|
|
|
- cur = con.cursor()
|
|
|
-
|
|
|
- cur.executescript(sqls)
|
|
|
- con.commit()
|
|
|
-
|
|
|
- con.close()
|
|
|
-
|
|
|
- except sqlite3.OperationalError:
|
|
|
- print(sqlite3.OperationalError.__name__)
|
|
|
-
|
|
|
-
|
|
|
-def exec_fetchall(dbPath:str="", sqls:str="", fetchAll:bool=True):
|
|
|
+def exec(dbPath:str="", sqls:str="", fetchAll:bool=False):
|
|
|
if dbPath != "" and sqls != "":
|
|
|
try:
|
|
|
con = sqlite3.connect(dbPath)
|