Skip to content

Commit 5d3afe2

Browse files
committed
account type, table setup initialisation
1 parent 2fc82b1 commit 5d3afe2

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

accounttype.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def acctype():
2+
while True:
3+
print("--------------Account Selector Menu--------------")
4+
print("1.Admin.")
5+
print("2.Employee.")
6+
print("3.Client.")
7+
print("Enter 0 to end process.")
8+
a=int(input("\nEnter your account type:"))
9+
10+
if a==1:
11+
b=input("\nEnter admin password:")
12+
if b=="admin123":
13+
return 1
14+
else:
15+
print("\nWrong password!\n")
16+
17+
elif a==2:
18+
b=input("\nEnter employee password:")
19+
if b=="emp123":
20+
return 2
21+
else:
22+
print("\nWrong password!\n")
23+
24+
elif a==3:
25+
return 3
26+
27+
elif a==0:
28+
print("\nShutting down the program.")
29+
break
30+
31+
else:
32+
print("\nWrong input!")

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import check
2+
import sqltables
23

34
import pickle
45
import mysql.connector
@@ -42,6 +43,7 @@ def querycheck():
4243
print("Connection established successfully.")
4344
with open("firsttime.txt","w") as f:
4445
f.write("False")
46+
sqltables.tables()
4547
ans=True
4648

4749
if not ans:

sqltables.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import setup
2+
import mysql.connector
3+
from mysql.connector import errorcode
4+
conn=setup.setup()
5+
cursor=conn.cursor()
6+
7+
DB_NAME = setup.sqldb()
8+
9+
TABLES = {}
10+
TABLES['employees'] = (
11+
"CREATE TABLE `employees` ("
12+
" `emp_no` int(5) NOT NULL AUTO_INCREMENT,"
13+
" `birth_date` date NOT NULL,"
14+
" `first_name` varchar(15) NOT NULL,"
15+
" `last_name` varchar(15) NOT NULL,"
16+
" `gender` enum('M','F') NOT NULL,"
17+
" `hire_date` date NOT NULL,"
18+
" `age` int(2) NOT NULL"
19+
" PRIMARY KEY (`emp_no`)"
20+
") ")
21+
22+
TABLES['client'] = (
23+
"CREATE TABLE `clients` ("
24+
" `acc_no` int(5) NOT NULL AUTO_INCREMENT,"
25+
" `acc_type` enum('S','C') NOT NULL"
26+
" `first_name` varchar(15) NOT NULL,"
27+
" `last_name` varchar(15) NOT NULL,"
28+
" `gender` enum('M','F') NOT NULL,"
29+
" `birth_date` date NOT NULL,"
30+
" `acc_creation_date` date NOT NULL,"
31+
" PRIMARY KEY (`acc_no`)"
32+
)
33+
34+
#https://education.github.com/git-cheat-sheet-education.pdf
35+
#https://dev.mysql.com/doc/connector-python/en/connector-python-example-ddl.html
36+

0 commit comments

Comments
 (0)