Browse Source

- config的app_command添加了更多的变量但是应该不是这样解决问题

NandHyf 1 year ago
parent
commit
2c68f7ca67
4 changed files with 18 additions and 9 deletions
  1. 11 6
      Stateful.py
  2. BIN
      __pycache__/Stateful.cpython-311.pyc
  3. 2 0
      debug_backlog.txt
  4. 5 3
      dev_config.toml

+ 11 - 6
Stateful.py

@@ -75,11 +75,16 @@ def MatchTomlKeys(tomlName, keys, table=None) -> list:
 def Operate_sqlite3(dbPath, match_commands):
     matchedSyntax = MatchTomlKeys("dev_config.toml", match_commands, "sqlite3")
 
-    s = " ".join(matchedSyntax)
+    s = "".join(matchedSyntax).format(tableName = match_commands[2])
+   
 
     con = sqlite3.connect(dbPath)
     cur = con.cursor()
     
+    res = cur.execute(s)
+    res.fetchone()
+    # if res = None:
+
     con.close()
 
 
@@ -118,11 +123,11 @@ def PackHandler(app_commands):
 
 
 if __name__ == "__main__":
-    
-    a_c = ['add', 'board', 'testBoardName', 'test.db', 'sqlite3']
-    a_c1 = ['edit', 'board', 't_boardName', 'to', 't_newBoardName', 'test.db', 'sqlite3']
+    a_c = ['/', 'test.db', 'sqlite3']
+    a_c1 = ['add', 'board', 'testBoardName', 'test.db', 'sqlite3']
+    a_c2 = ['edit', 'board', 't_boardName', 'to', 't_newBoardName', 'test.db', 'sqlite3']
     e_c = ['add', 'board']
-    
+
     # Operate_sqlite3("test.db", a_c1)
-    PackHandler(a_c)
+    PackHandler(a_c2)
     

BIN
__pycache__/Stateful.cpython-311.pyc


+ 2 - 0
debug_backlog.txt

@@ -7,5 +7,7 @@
 
 # ----- Stateful.py -----
 1. 读取toml文件时候没有匹配到键的异常处理: 已解决(通过table=None的参数)
+2. list board 之后返回None要不要做异常处理(成换行)
+3. add命令的判断: 是CREATE 还是 INSERT INTO
 
 # ----- Alt.py -----

+ 5 - 3
dev_config.toml

@@ -11,14 +11,16 @@ displayTime = "utc+8"
 # app_command[0] -> command1
 "/" = "SELECT name FROM sqlite_master WHERE type='table';"
 list = "SELECT "
+create = "CREATE "
 add = "INSERT INTO "
 edit = "UPDATE "
 delete = "UPDATE " # change stauts to "deleted"
 
 # app_command[1] -> obj1
-board = "TABLE {boardName} "
-class = "TABLE {className} "
-event = "TABLE {eventName} "
+board = "TABLE {tableName}({board_uid}, {board_name}, {status})"
+class = "TABLE {tableName}({class_uid}, {class_name}, {used_board}, {status})"
+event = "TABLE {tableName}({event_uid}, {event_name}, {event_dscrp}, {event_creator}, {createdTime}, {class_created}, {ddlTime}, {alertTime}, {currentClass}, {status})"
+stucked = "TABLE {tableName}({board_uid}, {event_uid}, {stucked_time}, {solved_time})"
 
 # app_command[2] -> tag1
 "-name" = ""