|
@@ -5,97 +5,75 @@ deType = "sqlite3"
|
|
|
dbPath = "dev.db"
|
|
|
|
|
|
|
|
|
-def is_exist(tableName, columnName):
|
|
|
- pass
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-def Secondary_response():
|
|
|
- pass
|
|
|
-
|
|
|
-
|
|
|
-def Operate_sqlite3(dbPath, commands):
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class Op_sqlite3():
|
|
|
+ def __init__(self, commands) -> None:
|
|
|
+ self.dbPath = dbPath
|
|
|
+ self.commands = commands
|
|
|
+ self.tableName = str(commands[1]).capitalize()
|
|
|
+ self.columnName = str(commands[2])
|
|
|
+
|
|
|
+ self.ItemName = str(commands[])
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- v = "SELECT * FROM {tableName} WHERE name={name}".format(tableName=str(commands[1]).capitalize(), name="'"+commands[2]+"'")
|
|
|
-
|
|
|
- con = sqlite3.connect(dbPath)
|
|
|
- cur = con.cursor()
|
|
|
-
|
|
|
- try:
|
|
|
- res = cur.execute(v)
|
|
|
+
|
|
|
+ def Exec(self):
|
|
|
+ con = sqlite3.connect(dbPath)
|
|
|
+ cur = con.cursor()
|
|
|
+
|
|
|
+ cur.execute(self.commands)
|
|
|
con.commit()
|
|
|
- print("res: ", res.fetchone() is None)
|
|
|
+ re = cur.fetchall()
|
|
|
+ con.close()
|
|
|
+
|
|
|
+ return re
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- if res.fetchone() is None == True:
|
|
|
- print("err <Code>: could not found, creat? y/n")
|
|
|
+ def IsExist(self, returnBool=True):
|
|
|
+ sqls = "SELECT {coumn} FROM {table} WHERE name='{name}'".format(column=self.columnName, table=self.tableName, name=self.ItemName)
|
|
|
+ ie = Op_sqlite3.Exec(sqls)
|
|
|
|
|
|
-
|
|
|
+ if ie != None and returnBool == False:
|
|
|
+ return ie
|
|
|
+
|
|
|
+ elif ie != None and returnBool == True:
|
|
|
+ return True
|
|
|
|
|
|
-
|
|
|
- matched = Stateful.MatchTomlKeys('dev_config.toml', commands, 'sqlite3')
|
|
|
- print(matched)
|
|
|
+ elif ie == None:
|
|
|
+ return False
|
|
|
+
|
|
|
+ else:
|
|
|
+ print("unexpected processing error")
|
|
|
|
|
|
|
|
|
- except:
|
|
|
- print("err <Code>: Syntax error")
|
|
|
+ def Secondary_response(self):
|
|
|
+ pass
|
|
|
|
|
|
- con.close()
|
|
|
+
|
|
|
+ def Regular(self):
|
|
|
+ try:
|
|
|
+ ie = Op_sqlite3.IsExist()
|
|
|
+
|
|
|
+ if ie != None:
|
|
|
+ Op_sqlite3.Exec(dbPath, sy_i)
|
|
|
+
|
|
|
+ except:
|
|
|
+ print("not exist")
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
while(1):
|
|
|
sy_i = input("sql: ").split(" ")
|
|
|
- Operate_sqlite3(dbPath, sy_i)
|
|
|
+ Op_sqlite3.Regular(dbPath, sy_i)
|
|
|
+
|
|
|
+
|