0% found this document useful (0 votes)
162 views2 pages

Main Bank - Py

Uploaded by

f18783008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views2 pages

Main Bank - Py

Uploaded by

f18783008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import mysql.

connector as sql
conn=sql.connect(host='localhost',user='root',passwd='Dhruvin',database='bank')
cur = conn.cursor()
#cur.execute('create table user_table(username varchar(25) primary key,passwrd
varchar(25) not null )')
print '=========================WELCOME TO STARK BANK=========================='
import datetime as dt
print dt.datetime.now()
print
"----------------------------------------------------------------------------------
-------------------------"
def main_bank():
print '1.REGISTER'
print '2.LOGIN'
print
"----------------------------------------------------------------------------------
-------------------------"
n=int(input('Enter your choice:'))
print
"----------------------------------------------------------------------------------
-------------------------"

if n== 1:
cur.execute('select username from user_table; ')
un=cur.fetchall()
print "------------------------------------------- REGISTER
--------------------------------------------------"
name=raw_input('Enter a Username:')
if un!=None:
for k in un:
if name==k[0]:
print "User Name already exists."
print "Please enter valid User Name."
print
"----------------------------------------------------------------------------------
-----"
main_bank()

def reg():
for i in range(5):
passwd=raw_input('Enter a 4 DIGIT Password:')
if passwd.isdigit():
if len(passwd)==4:
break
elif i==4 and len(passwd)!=4:
print "Sorry you lost your chances!!!!!"
print
"----------------------------------------------------------------------------------
-----"
main_bank()
else:
print "Enter valid password!!"
print
"----------------------------------------------------------------------------------
-----"
elif i==4 and passwd.isdigit()==False:
print "Sorry you lost your chances!!"
print "--------------------------------------------"
else:
print "Enter valid number!!"
print
"----------------------------------------------------------------------------------
-----"

cur.execute("INSERT INTO user_table (username, passwrd) values


('{0}',{1})".format(name,passwd))
conn.commit()
print 'USER created succesfully'
print
"----------------------------------------------------------------------------------
-------------------------"
import menu
reg()

if n==2 :
print "--------------------------------------------- LOGIN
---------------------------------------------------"
name=raw_input('Enter your Username :')
passwd=raw_input('Enter your 4 DIGIT Password :')
print
"----------------------------------------------------------------------------------
-------------------------"
cur.execute("select * from user_table where passwrd="+(passwd))
pas=cur.fetchall()
x=0
if pas!=[]:
for k in pas:
if k[0]==name:
if k[1]==passwd:
x=x+1
if x==1:
import menu
else:
print 'Invalid username or password'
print
"----------------------------------------------------------------------------------
-------------------------"
main_bank()

main_bank()

You might also like