Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__/
firsttime.txt
cred.dat
cred.dat
links.txt
32 changes: 32 additions & 0 deletions accounttype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def acctype():
while True:
print("--------------Account Selector Menu--------------")
print("1.Admin.")
print("2.Employee.")
print("3.Client.")
print("Enter 0 to end process.")
a=int(input("\nEnter your account type:"))

if a==1:
b=input("\nEnter admin password:")
if b=="admin123":
return 1
else:
print("\nWrong password!\n")

elif a==2:
b=input("\nEnter employee password:")
if b=="emp123":
return 2
else:
print("\nWrong password!\n")

elif a==3:
return 3

elif a==0:
print("\nShutting down the program.")
break

else:
print("\nWrong input!")
96 changes: 92 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,81 @@
import pickle
import mysql.connector

from mysql.connector import errorcode

TABLES = {}
TABLES['employees'] = (
"CREATE TABLE `employees` ("
" `emp_no` int(5) NOT NULL AUTO_INCREMENT,"
" `birth_date` date NOT NULL,"
" `first_name` varchar(15) NOT NULL,"
" `last_name` varchar(15) NOT NULL,"
" `gender` enum('M','F') NOT NULL,"
" `hire_date` date NOT NULL,"
" `age` int(2) NOT NULL,"
" PRIMARY KEY (`emp_no`)"
") ")

TABLES['clients'] = (
"CREATE TABLE `clients` ("
" `acc_no` int(5) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
" `acc_type` enum('S','C') NOT NULL,"
" `first_name` varchar(15) NOT NULL,"
" `last_name` varchar(15) NOT NULL,"
" `gender` enum('M','F') NOT NULL,"
" `birth_date` date NOT NULL,"
" `acc_creation_date` date NOT NULL,"
" `mobile_no` int(10) NOT NULL,"
" `email_id` varchar(25) NOT NULL"
") "
)

TABLES['savings'] = (
"CREATE TABLE `savings` ("
" `acc_no` int(5) NOT NULL,"
" `balance` int NOT NULL,"
" `loan` enum('YES','NO') NOT NULL,"
" PRIMARY KEY (`acc_no`),"
" FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)"
") "
)

TABLES['current'] = (
"CREATE TABLE `current` ("
" `acc_no` int(5) NOT NULL,"
" `balance` int NOT NULL,"
" `overdraft` int NOT NULL,"
" PRIMARY KEY (`acc_no`),"
" FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)"
") "
)

TABLES['loan'] = (
"CREATE TABLE `loan` ("
" `acc_no` int(5) NOT NULL,"
" `loan_type` enum('PL','HL','EL','TL','BL') NOT NULL,"
" `loan_amt` int NOT NULL,"
" `time_period_months` int NOT NULL,"
" `iterest_perc_per_annum` int(1) NOT NULL,"
" `amt-per-month` int NOT NULL,"
" `remaining_amt` int NOT NULL,"
" PRIMARY KEY (`acc_no`),"
" FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)"
") "
)

TABLES['overdraft']=(
"CREATE TABLE `overdraft` ("
" `acc_no` int(5) NOT NULL,"
" `overdraft_amt` int NOT NULL,"
" `od_with_interest_remaining` int NOT NULL,"
" PRIMARY KEY (`acc_no`),"
" FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)"
") "
)


############################################################################################
query=""
Password=""
Database=""
Expand Down Expand Up @@ -40,9 +114,24 @@ def querycheck():
if conn!="":
if conn.is_connected:
print("Connection established successfully.")
with open("firsttime.txt","w") as f:
f.write("False")
ans=True
if check.check()==True:
cursor=conn.cursor()
#Table creation
for table_name in TABLES:
table_description = TABLES[table_name]
try:
print("Creating table {}: ".format(table_name), end='')
cursor.execute(table_description)
except mysql.connector.Error as err:
if err.errno == errorcode.ER_TABLE_EXISTS_ERROR:
print("already exists.")
else:
print(err.msg)
else:
print("OK")
with open("firsttime.txt","w") as f:
f.write("False")
ans=True

if not ans:
print("There was a problem in connection")
Expand Down Expand Up @@ -81,4 +170,3 @@ def setup():
else:
if querycheck():
connectionquery()
setup()