|
@@ -1,58 +1,6 @@
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
|
-# ----- Sqlite Methods -----
|
|
|
-def exec(dbPath):
|
|
|
- def dec():
|
|
|
- pass
|
|
|
-
|
|
|
-
|
|
|
-@exec("dev.db")
|
|
|
-def exec_one(dbPath:str, commands:list, fetchall:bool=False):
|
|
|
- con = sqlite3.connect(dbPath)
|
|
|
- cur = con.cursor()
|
|
|
-
|
|
|
- cur.execute(commands)
|
|
|
- con.commit()
|
|
|
-
|
|
|
- # if fetchall == input, return 0?
|
|
|
- if fetchall == True:
|
|
|
- re = cur.fetchall()
|
|
|
- return re
|
|
|
-
|
|
|
- cur.close()
|
|
|
- con.close()
|
|
|
-
|
|
|
- return 0
|
|
|
-
|
|
|
-@exec()
|
|
|
-def exec_many():
|
|
|
- pass
|
|
|
-
|
|
|
-
|
|
|
-def recordExist(dbPath:str, tableName:str, capitalize:bool=False, itemName:str="", returnBool:bool=True):
|
|
|
- # [todo 4] 这里面.capitalize()后面需要根据config.toml里面的内容判断
|
|
|
- # 可能也不用, 因为KBCLEV的表名和本身并无关系
|
|
|
- if capitalize == True:
|
|
|
- tableName = tableName.capitalize()
|
|
|
-
|
|
|
- sqls = "SELECT name FROM {table} WHERE name='{name}'".format(table=tableName, name=itemName)
|
|
|
- ie = exec_one(dbPath, sqls)
|
|
|
-
|
|
|
- if ie != [] and returnBool == False:
|
|
|
- return ie
|
|
|
-
|
|
|
- elif ie != [] and returnBool == True:
|
|
|
- return True
|
|
|
-
|
|
|
- elif ie == []:
|
|
|
- return False
|
|
|
-
|
|
|
- else:
|
|
|
- # Alt.Err(errCode)
|
|
|
- print("err <Code>: unexpected error in existence check")
|
|
|
-
|
|
|
-
|
|
|
# ----- Record_main(DB record as a class) -----
|
|
|
class RM():
|
|
|
def __init__(self, type:str="", name:str="", dscrp:str="", creator:str="", relatedBoard:str="", relatedClass:str="", state:int=-10) -> None:
|
|
@@ -99,7 +47,7 @@ class RM():
|
|
|
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)
|
|
|
|
|
|
|
|
|
- def get_styles():
|
|
|
+ def get_style():
|
|
|
pass
|
|
|
|
|
|
|
|
@@ -119,3 +67,81 @@ class DB():
|
|
|
|
|
|
def reGenerate():
|
|
|
pass
|
|
|
+
|
|
|
+
|
|
|
+# ----- Operating Cursor -----
|
|
|
+oc = {
|
|
|
+"dt":str, # DBType
|
|
|
+"dp":str, # DBPath
|
|
|
+
|
|
|
+"cp":list, # CurrentPath
|
|
|
+"pp":list, # PreviousPath
|
|
|
+
|
|
|
+"next_move":str,
|
|
|
+
|
|
|
+"tp":list, # TargetPath
|
|
|
+"tp_in":list, # ~ after command parameter "in"(&& before command parameter "to")
|
|
|
+"tp_to":list, # ~ after command parameter "to"
|
|
|
+"tp_attr":str # ~ like "-name" in "edit -name oldName to newName"
|
|
|
+}
|
|
|
+# some thoughts:
|
|
|
+# class oc():
|
|
|
+# def get_oc(), def move_oc()
|
|
|
+
|
|
|
+
|
|
|
+# ----- Sqlite Methods -----
|
|
|
+def execute(dbPath):
|
|
|
+ def dec(origin_func):
|
|
|
+ pass
|
|
|
+ con = sqlite3.connect(dbPath)
|
|
|
+ cur = con.cursor()
|
|
|
+
|
|
|
+ cur.execute(commands)
|
|
|
+ con.commit()
|
|
|
+
|
|
|
+ # if fetchall == input, return 0?
|
|
|
+ if fetchall == True:
|
|
|
+ re = cur.fetchall()
|
|
|
+ return re
|
|
|
+
|
|
|
+ cur.close()
|
|
|
+ con.close()
|
|
|
+ def dec():
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+@execute(oc["dp"])
|
|
|
+def exec_one(dbPath:str, commands:list, fetchall:bool=False):
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+@execute(oc["dp"])
|
|
|
+def exec_many():
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+def recordExist(dbPath:str, tableName:str, capitalize:bool=False, itemName:str="", returnBool:bool=True):
|
|
|
+ # [todo 4] 这里面.capitalize()后面需要根据config.toml里面的内容判断
|
|
|
+ # 可能也不用, 因为KBCLEV的表名和本身并无关系
|
|
|
+ if capitalize == True:
|
|
|
+ tableName = tableName.capitalize()
|
|
|
+
|
|
|
+ sqls = "SELECT name FROM {table} WHERE name='{name}'".format(table=tableName, name=itemName)
|
|
|
+ ie = exec_one(dbPath, sqls)
|
|
|
+
|
|
|
+ if ie != [] and returnBool == False:
|
|
|
+ return ie
|
|
|
+
|
|
|
+ elif ie != [] and returnBool == True:
|
|
|
+ return True
|
|
|
+
|
|
|
+ elif ie == []:
|
|
|
+ return False
|
|
|
+
|
|
|
+ else:
|
|
|
+ # Alt.Err(errCode)
|
|
|
+ print("err <Code>: unexpected error in existence check")
|
|
|
+
|
|
|
+
|
|
|
+def master():
|
|
|
+ pass
|