소스 검색

忘记给另一个套exception了

nandHyf 1 년 전
부모
커밋
235e881c3f
1개의 변경된 파일9개의 추가작업 그리고 5개의 파일을 삭제
  1. 9 5
      kbc_sqlite.py

+ 9 - 5
kbc_sqlite.py

@@ -93,13 +93,17 @@ oc = {
 # ----- Execute Methods -----
 def exec(dbPath:str="", sqls:str=""):
     if dbPath != "" and sqls != "":
-        con = sqlite3.connect(dbPath)
-        cur = con.cursor()
+        try:
+            con = sqlite3.connect(dbPath)
+            cur = con.cursor()
 
-        cur.executescript(sqls)
-        con.commit()
+            cur.executescript(sqls)
+            con.commit()
 
-        con.close()
+            con.close()
+            
+        except sqlite3.OperationalError:
+            print(sqlite3.OperationalError.__name__)
 
 
 def exec_fetchall(dbPath:str="", sqls:str="", fetchAll:bool=True):