Răsfoiți Sursa

이렇게 하자

2DU 8 ani în urmă
părinte
comite
00264bba65
1 a modificat fișierele cu 17 adăugiri și 10 ștergeri
  1. 17 10
      app.py

+ 17 - 10
app.py

@@ -12,19 +12,26 @@ try:
     json_data = open('set.json').read()
     set_data = json.loads(json_data)
 except:
-    new_json = []
+    while(1):
+        new_json = []
 
-    print('DB 이름 : ', end = '')
-    new_json += [input()]
+        print('DB 이름 : ', end = '')
+        new_json += [input()]
 
-    print('포트 : ', end = '')
-    new_json += [input()]
+        print('포트 : ', end = '')
+        new_json += [input()]
 
-    with open("set.json", "w") as f:
-        f.write('{ "db" : "' + new_json[0] + '", "port" : "' + new_json[1] + '" }')
-    
-    json_data = open('set.json').read()
-    set_data = json.loads(json_data)
+        if(new_json[0] != '' and new_json[1] != ''):
+            with open("set.json", "w") as f:
+                f.write('{ "db" : "' + new_json[0] + '", "port" : "' + new_json[1] + '" }')
+            
+            json_data = open('set.json').read()
+            set_data = json.loads(json_data)
+
+            break
+        else:
+            print('모든 값을 입력하세요.')
+            pass
 
 conn = sqlite3.connect(set_data['db'] + '.db')
 curs = conn.cursor()