Skip to content

Instantly share code, notes, and snippets.

@gptshubham595
Last active March 26, 2021 19:51
Show Gist options
  • Save gptshubham595/31aa21c285c86c46fa61d4c224b42506 to your computer and use it in GitHub Desktop.
Save gptshubham595/31aa21c285c86c46fa61d4c224b42506 to your computer and use it in GitHub Desktop.
import mysql
import mysql.connector
import pickle
from tabulate import tabulate
mydb=mysql.connector.connect(user = 'root',
passwd = '',
host = 'localhost',
database = 'project',
)
cur=mydb.cursor(buffered=True)
data=""
def first():
b=input("enter name : ")
c=input("enter mobile : ")
d=input("enter email :")
e=input("enter city :")
f=input("enter country : ")
g=input("enter balance : ")
data="insert into account (name,mobile,email,city,country,balance) values (%s,%s,%s,%s,%s,%s)"
values=(b+"",c+"",d+"",e+"",f+"",g+"")
try:
cur.execute(data,values)
mydb.commit()
print("NEW ACCOUNT CREATED SUCCESSFULLY!!")
except:
print("ERR!")
choice =input("want to add another account YES/NO : ")
if choice.lower() =="yes" or choice.lower()=='y':
print("\n")
first()
else:
print("\n")
menu()
##-----------------------------------
def second():
print(" a.sorted as per account number")
print(" b.sorted as per customer name")
print(" c.sorted as per customer balance")
o=input("enter any option a/b/c to perform above action : ")
result=""
if o=="a":
cur.execute("select accno,name,mobile,email,city,country,balance from account order by accno;")
result= cur.fetchall()
print(tabulate(result,headers=["accno","name","mobile","email","city","country","balance"],tablefmt="psql"))
elif o=="b":
cur.execute("select accno,name,mobile,email,city,country,balance from account order by name;")
result = cur.fetchall()
print(tabulate(result,headers=["accno","name","mobile","email","city","country","balance"],tablefmt="psql"))
elif o=="c":
cur.execute("select accno,name,mobile,email,city,country,balance from account order by balance;")
result = cur.fetchall()
print(tabulate(result,headers=["accno","name","mobile","email","city","country","balance"],tablefmt="psql"))
q=input("wan't to continue sorting type YES/NO : ")
if q.lower() =="yes" or q.lower()=='y':
second()
else:
menu()
##-----------------------------------
def fourth():
z=input("enter account number to update your record = ")
bb=input("enter name : ")
cc=input("enter mobile : ")
dd=input("enter email : ")
ee=input("enter city : ")
ff=input("enter country : ")
gg=input("enter balance : ")
data="update account set name=%s ,mobile=%s,email=%s,city=%s,country=%s,balance=%s where accno=%s; "
values=(bb+"",cc+"",dd+"",ee+"",ff+"",gg+"",z+"")
try:
cur.execute(data,values)
mydb.commit()
print("SUCCESSFULLY UPDATED!!")
except:
print("ERR!")
menu()
##-----------------------------------
def deposit(sixx,t):
data="update account set balance =balance + %s where accno = %s;"
value=(sixx+"",t+"")
try:
cur.execute(data,value)
mydb.commit()
data="update credit set deposit = %s where accno = %s;"
value=(sixx+"",t+"")
cur.execute(data,value)
mydb.commit()
print("SUCCESSFULLY DEPOSITED!!")
menu()
except:
print("ERR!")
##-----------------------------------
def depo(sixx,t):
data="update account set balance =balance + %s where accno = %s;"
value=(sixx+"",t+"")
try:
cur.execute(data,value)
mydb.commit()
data="update credit set deposit = %s where accno = %s;"
value=(sixx+"",t+"")
cur.execute(data,value)
mydb.commit()
print("AMOUNT TRANSFERRED SUCCESSFULLY !!")
menu()
except:
print("ERR!")
##MENU---------------------------------------
def menu():
print("*"*140)
print(' WELCOME TO BANK OF INDIA ')
print("MAIN MENU")
print("1.insert record/records")
print("2.display records")
print(" a.sorted as per account number")
print(" b.sorted as per customer name")
print(" c.sorted as per customer balance")
print("3.search record details as per the account number ")
print("4.update record")
print("5.delete record")
print("6.deposite/withdraw from the account")
print("7.online banking")
print("8.exit")
print("*"*140)
##first--------------------------
n =int(input("enter your choice ="))
if n==1:
first()
##second-------------------------
elif n==2:
cur.execute("select * from account;")
result=""
result = cur.fetchall()
print(tabulate(result,headers=["accno","name","mobile","email","city","country","balance"],tablefmt="psql"))
second()
##third--------------------------
elif n==3:
t=input("ENTER ACCOUNT NUMBER TO SEARCH YOUR DETAILS = ")
cur.execute("select accno,name,mobile,email,city,country,balance from account where accno="+t+";")
result3 = cur.fetchall()
print(tabulate(result3,headers=["accno","name","mobile","email","city","country","balance"],tablefmt="psql"))
##fourth--------------------------
elif n==4:
fourth()
##fifth---------------------------
elif n==5:
f=input("ENTER ACCOUNT NUMBER TO DELETE YOUR RECORD = ")
try:
cur.execute("delete from account where accno="+f+";")
mydb.commit()
print("SUCCESSFULLY DELETED!!")
menu()
except:
print("ERR!")
##sixth---------------------------
elif n==6:
t=input("ENTER ACCOUNT NUMBER = ")
six=input("want to deposit(dep) or withdraw(wit) : ")
if six=="dep":
sixx=input("enter balance to deposit your money = ")
deposit(sixx,t)
elif six=="wit":
sixx=input("enter balance to withdraw your money = ")
data="update account set balance =balance - %s where accno = %s;"
value=(sixx+"",t+"")
try:
cur.execute(data,value)
mydb.commit()
data="update credit set withdraw = %s where accno = %s;"
value=(sixx+"",t+"")
cur.execute(data,value)
mydb.commit()
print("SUCCESSFULLY withdrawn!!")
menu()
except:
print("ERR!")
##seventh---------------------------
elif n==7:
print(" ONLINE BANKING")
tran1=input("enter your account number = ")
bal=input("enter amount to send = ")
data="update account set balance =balance - %s where accno = %s;"
value=(bal+"",tran1+"")
cur.execute("select accno,name from account;")
res=cur.fetchall()
print(tabulate(res,headers=["accno","name"],tablefmt="psql"))
try:
cur.execute(data,value)
mydb.commit()
except:
print("ERR!")
tran2=input("enter receivers account number = ")
depo(bal,tran2)
menu()
##eighth---------------------------
elif n==8:
pass
print("PROGRAM STOPPED")
##------------------------------------------
##end-----------
##------------------------------------------
def main():
menu()
if _name=='main_':
main()
delay(100);
}
}
void p1slot2() // parking 1 slot2
{
if( digitalRead(parking1_slot2_ir_s) == LOW)
{
sensor2 = "255";
analogWrite(LED2,255);
delay(100);
}
if( digitalRead (parking1_slot2_ir_s) == HIGH)
{
sensor2 = "0";
analogWrite(LED2,0);
delay(100);
}
}
void p2slot1() // parking 1 slot3
{
if( digitalRead(parking2_slot1_ir_s) == LOW)
{
sensor3 = "255";
analogWrite(LED3,255);
delay(100);
}
if( digitalRead(parking2_slot1_ir_s) == HIGH)
{
sensor3 = "0";
analogWrite(LED3,0);
delay(100);
}
}
void p2slot2() // parking 1 slot3
{
if( digitalRead(parking2_slot2_ir_s) == LOW)
{
sensor4 = "255";
analogWrite(LED4,255);
delay(100);
}
if( digitalRead(parking2_slot2_ir_s) == HIGH)
{
sensor4 = "0";
analogWrite(LED4,0);
delay(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment