55
66from mysql .connector import errorcode
77existing = 0
8+
9+ conn = None
10+ cursor = None
11+
812TABLES = {}
913TABLES ['employees' ] = (
1014 "CREATE TABLE `employees` ("
2731 " `birth_date` date NOT NULL,"
2832 " `acc_creation_date` date NOT NULL,"
2933 " `mobile_no` int(10) NOT NULL,"
30- " `email_id` varchar(25) NOT NULL"
34+ " `email_id` varchar(25) NOT NULL,"
35+ " `pass` varchar(8) NOT NULL"
36+ ") "
37+ )
38+
39+ TABLES ['empass' ] = (
40+ "CREATE TABLE `empass` ("
41+ " `emp_no` int(5) NOT NULL,"
42+ " `pass` varchar(8) NOT NULL,"
43+ " PRIMARY KEY (`emp_no`),"
44+ " FOREIGN KEY(`emp_no`) REFERENCES employees(emp_no)"
3145 ") "
3246)
3347
48+
3449TABLES ['savings' ] = (
3550 "CREATE TABLE `savings` ("
3651 " `acc_no` int(5) NOT NULL,"
@@ -108,6 +123,8 @@ def connectionquery():
108123 return query
109124
110125def querycheck ():
126+ global conn
127+ global cursor
111128 global existing
112129 conn = connectionquery ()
113130 ans = False
@@ -130,8 +147,6 @@ def querycheck():
130147 print (err .msg ())
131148 else :
132149 print ("OK" )
133- with open ("firsttime.txt" ,"w" ) as f :
134- f .write ("False" )
135150 ans = True
136151
137152 if not ans :
@@ -152,6 +167,8 @@ def mysqlsetup():
152167 querycheck ()
153168
154169def setup ():
170+ global cursor
171+ global conn
155172 global existing
156173 while check .check ():
157174 print ("\n \n -----------------Welcome to the Project!!!-------------------" )
@@ -165,7 +182,7 @@ def setup():
165182 break
166183 if ans2 == "1" :
167184 mysqlsetup ()
168- if existing == 6 :
185+ if existing == 7 :
169186 with open ("firsttime.txt" ,"w" ) as f :
170187 f .write ("False" )
171188 continue
@@ -175,4 +192,4 @@ def setup():
175192 print ("\n Wrong input, (1/2)........." )
176193 else :
177194 if querycheck ():
178- connectionquery ()
195+ return True
0 commit comments