12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import sqlite3
- import Stateful
- deType = "sqlite3"
- dbPath = "dev.db"
- 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[])
-
- def Exec(self):
- con = sqlite3.connect(dbPath)
- cur = con.cursor()
- cur.execute(self.commands)
- con.commit()
- re = cur.fetchall()
- con.close()
- return re
-
- 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
- elif ie == None:
- return False
-
- else:
- print("unexpected processing error")
- def Secondary_response(self):
- pass
-
- 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(" ")
- Op_sqlite3.Regular(dbPath, sy_i)
-
|