direct.py 727 B

1234567891011121314151617181920212223242526272829303132333435
  1. import sqlite3
  2. import Stateful
  3. def Operate_sqlite3(dbPath, commands):
  4. con = sqlite3.connect(dbPath)
  5. cur = con.cursor()
  6. # 1. exist check
  7. try:
  8. res = cur.execute(commands)
  9. con.commit()
  10. print("res.fetchone() is None: ", res.fetchone() is None)
  11. # syntax right but not exist:
  12. if res.fetchone() is None == True:
  13. print("err <Code>: could not found, creat? y/n")
  14. except:
  15. print("err <Code>: Syntax error")
  16. con.close()
  17. if __name__ == "__main__":
  18. # while(1):
  19. # syi = input("sql: ").split()
  20. # sy_i = input("sql: ")
  21. # Operate_sqlite3("dev.db", sy_i)
  22. data = [
  23. ('null', 'CL2', 'KB2', 'alive')
  24. ]
  25. sqls = ""