1234567891011121314151617181920212223242526272829 |
- import sqlite3
- def Operate_sqlite3(dbPath, commands):
- con = sqlite3.connect(dbPath)
- cur = con.cursor()
-
- try:
- res = cur.execute(commands)
- con.commit()
- print("res.fetchone() is None: ", res.fetchone() is None)
-
- if res.fetchone() is None == True:
- print("err <Code>: could not found, creat? y/n")
- except:
- print("err <Code>: Syntax error")
- con.close()
- if __name__ == "__main__":
- while(1):
-
- sy_i = input("sql: ")
- Operate_sqlite3("dev.db", sy_i)
|