Browse Source

- 小改动

nandHyf 1 year ago
parent
commit
fb816d71a3
3 changed files with 67 additions and 54 deletions
  1. 0 30
      debug_backlog.md
  2. 19 7
      dev_config.toml
  3. 48 17
      sqlite.py

+ 0 - 30
debug_backlog.md

@@ -54,36 +54,6 @@
 > /<boardName>/: select class <boardName2>/<className>
 
 
-# ----- 要不先整理一下后端的句子,前端太难搞了 -----
-[CREATE TABLE]
-CREATE TABLE Board(board_uid, board_name, status)
-CREATE TABLE Class(class_uid, class_name, using_board, status)
-CREATE TABLE Event(event_uid, event_name, event_dscrp, event_creator, createdTime, belongBoard, class_created, ddlTime, alertTime, currentClass, status)
-CREATE TABLE Stucked(board_uid, event_uid, stucked_time, solved_time)
-CREATE TABLE Alert(event_uid, alert_time, status)
-CREATE TABLE Ddl(event_uid, ddlTime, status)
-
-[SELECT ]
-select:
-
-
-[INSERT INTO]
-INSERT INTO <Board/Class/Event/Stucked/Alert/Ddl>
-
-[UPDATE ]
-edit:
-UPDATE <table> SET <column> WHERE uid = <uid>
-
-delete:
-UPDATE <table> SET status WHERE uid = <uid>
-
-
-[DROP ]
-wipe:
-
-erase:
-
-
 # ----- 前端输入 -----
 [add]
 > add board <boardName>

+ 19 - 7
dev_config.toml

@@ -6,24 +6,36 @@ lang = "en"
 listStyle = "tree"
 displayTime = "utc+8"
 
+
 # ----- App Command to DB Syntax Translation -----
+[sqlite3.init]
+DBType = "sqlite3"
+# Table name
+Board = ""
+Class = ""
+Event = ""
+Stuck = ""
+Alert = ""
+DDL = ""
+
 [sqlite3]
 # app_command[0]
 "/" = "SELECT name FROM sqlite_master WHERE type='table';"
 select = "SELECT "
-create = "CREATE "
-add = "INSERT INTO TABLE "
+add = "INSERT INTO "
 edit = "UPDATE "
 delete = "UPDATE " # change stauts to "deleted"
+wipe="DROP WHERE"
 
 # app_command[1]
-board = "TABLE "
-class = "TABLE "
-event = "TABLE "
+board = "({uid}, {name}, {status}).format(uid='', name='', status='live')"
+class = "({uid}, {name}, {usedBoard}, {status})"
+event = "({uid}, {name}, {dscrp}, {createdTime}, {belongBoard}, {classCreated}, {currentClas}, {status})"
+
 # "/" -> " " in Stateful
-stucked = "TABLE "
+stucked = "Stucked "
 
 # app_command[3] && [4]
 "-d" = ""
 "-ddl" = ""
-to = "here is to"
+to = "here is to"

+ 48 - 17
sqlite.py

@@ -2,7 +2,7 @@ import sqlite3
 import Stateful
 
 deType = "sqlite3"
-dbPath = "dev.db"
+dbPath = "d<EV>.db"
 
 
 def is_exist(tableName, columnName):
@@ -13,16 +13,52 @@ def Secondary_response():
 
 
 def Operate_sqlite3(dbPath, commands):
-    #                 0       1       2     3      4     5     6
-    # commands e.g.['add', 'board', 'KB4']
-    # commands e.g.['add', 'class', 'CL1', 'to', 'KB4']
-    # commands e.g.['add', 'event', 'EV1', 'to', 'KB4', '/', 'CL2']
-    # commands e.g.['add', 'event', 'EV2', 'to', 'KB4/CL3']
+    # Command e.g.
+    #    0       1       2      3      4      5     6
+    # [add]
+    # ['add', 'board', '<KB>']
+    # ['add', 'class', '<CL>', 'to', '<KB>']
+    # ['add', 'event', '<EV>', 'to', '<KB>', '/', '<CL>'] <- 这个应该报错
+    # ['add', 'event', '<EV>', 'to', '<KB>/<CL>']
 
-    v = "SELECT * FROM {tableName} WHERE name={name}".format(tableName=str(commands[1]).capitalize(), name="'"+commands[2]+"'")
+    # [edit]
+    # ['edit', 'board', '<KB>', 'to', '<KB>']
+    # ['edit', 'class', '<KB>', 'to', '<KB>']
+    # ['edit', 'class', '<CL>', 'to', '<CL>']
+    # ['edit', 'class', '<CL>', 'to', '<CL>']
+    # ['edit', 'event', '<EV>', 'to', '<EV>']
+    # ['edit', 'event', '<EV>', 'in', '<KB>', '/', '<CL>'] <- 这个应该报错
+    # ['edit', 'event', '<EV>', 'in', '<KB>/<CL>']
+
+    # [delete]
+    # ['delete', 'board', '<KB>']
+    # ['delete', 'class', '<CL>']
+    # ['delete', 'event', '<EV>']
+    # ['delete', 'event', '<EV>', 'in', '<KB>', '/', '<CL>'] <- 这个应该报错
+    # ['delete', 'event', '<EV>', 'in', '<KB>/<CL>']
+
+    # [move]
+    # ['move', 'class', '<CL>', 'to', '<KB>']
+    # ['move', 'event', '<EV>', 'to', '<KB>']
+    # ['move', 'event', '<EV>', 'to', '<CL>']
+    # ['move', 'event', '<EV>', 'in', '<KB>', '/', '<CL>'] <- 这个应该报错
+    # ['move', 'event', '<EV>', 'in', '<KB>/<CL>']
+
+    # [select]
+    # ['select', 'board', '<KB>']
+    # ['select', 'class', '<CL>']
+    # ['select', 'event', '<EV>']
+    # ['select', 'event', '<EV>', 'in', '<KB>', '/', '<CL>'] <- 这个应该报错
+    # ['select', 'event', '<EV>', 'in', '<KB>/<CL>']
+
+    # [..]
+
+    # [/]
+    
     
-    # sqls = ""
 
+    v = "SELECT * FROM {tableName} WHERE name={name}".format(tableName=str(commands[1]).capitalize(), name="'"+commands[2]+"'")
+    
     con = sqlite3.connect(dbPath)
     cur = con.cursor()
     # 1. exist check
@@ -34,11 +70,14 @@ def Operate_sqlite3(dbPath, commands):
         # syntax right but not exist:
         if res.fetchone() is None == True:
             print("err <Code>: could not found, creat? y/n")
+
             # Secondary_response()
+
         # 2. exec command
-        matched = Stateful.MatchTomlKeys('dev_config.toml', commands, 'sqlite3')
+        matched = Stateful.MatchTomlKeys('d<EV>_config.toml', commands, 'sqlite3')
         print(matched)
 
+
     except:
         print("err <Code>: Syntax error")
 
@@ -46,14 +85,6 @@ def Operate_sqlite3(dbPath, commands):
 
 
 if __name__ == "__main__":
-    sy = "CREATE TABLE Board(board_uid, board_name, status)"
-    sy1 = "INSERT INTO Board VALUES('1', 'board1', 'live');"
-    sy2 = "DROP TABLE test;"
-    sy3 = "DROP TABLE Board"
-    sy4 = "CREATE TABLE Board(uid, name, status)"
-    sy5 = "INSERT INTO Board VALUES('1', 'KB1', 'live');"
-
-    sy6 = ['add', 'board', 'KB1']
 
     while(1):
         sy_i = input("sql: ").split(" ")