Skip to content

Commit 2ac3e89

Browse files
committed
fixed major bugs (to continue if tables already exist)
1 parent 7b2b923 commit 2ac3e89

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def check():
22
with open("firsttime.txt","r") as a:
3-
if a.read()=="True":
3+
if a.read().strip()=="True":
44
return True
55
else:
66
return False

firsttime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
True
1+
False

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import mysql.connector
55

66
from mysql.connector import errorcode
7-
7+
existing=0
88
TABLES = {}
99
TABLES['employees'] = (
1010
"CREATE TABLE `employees` ("
@@ -109,6 +109,7 @@ def connectionquery():
109109
return query
110110

111111
def querycheck():
112+
global existing
112113
conn=connectionquery()
113114
ans=False
114115
if conn!="":
@@ -125,6 +126,7 @@ def querycheck():
125126
except mysql.connector.Error as err:
126127
if err.errno == errorcode.ER_TABLE_EXISTS_ERROR:
127128
print("already exists.")
129+
existing+=1
128130
else:
129131
print(err.msg)
130132
else:
@@ -151,6 +153,7 @@ def mysqlsetup():
151153
querycheck()
152154

153155
def setup():
156+
global existing
154157
while check.check():
155158
print("\n\n-----------------Welcome to the Project!!!-------------------")
156159
print("This is the setup process which runs when the user uses the program for the first time.")
@@ -163,6 +166,10 @@ def setup():
163166
break
164167
if ans2=="1":
165168
mysqlsetup()
169+
if existing==6:
170+
with open("firsttime.txt","w") as f:
171+
f.write("False")
172+
continue
166173
if ans2=="2":
167174
print("\nThis is under development :). Please use mysql till then...")
168175
elif ans2 != "1" or ans2 != "2":

0 commit comments

Comments
 (0)