0% found this document useful (0 votes)
30 views4 pages

SHRIPARNA SHUKLA - Py

The document contains code to create a banking system with MySQL. It allows users to create an account, login, deposit, withdraw, transfer money and check balances. Functions include selecting, inserting, updating database records.
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)
30 views4 pages

SHRIPARNA SHUKLA - Py

The document contains code to create a banking system with MySQL. It allows users to create an account, login, deposit, withdraw, transfer money and check balances. Functions include selecting, inserting, updating database records.
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/ 4

import mysql.

connector as sql

conn = sql.connect(host='localhost', user='root', password='12344321',


database='ATM_MACHINE')
c1 = conn.cursor()

print("============================================================================
====") print(" WELCOME TO OUR BANK ")
print("============================================================================
====")
print("1. To create account") print("2. To login") print("3. Exit")
print("============================================================================
====")

op = int(input("Enter your choice: "))


print("============================================================================
====")

if op == 1:
c = "y"
while c == "y":
m = int(input("Enter a 4 digit number as account number: ")) cb = "SELECT * FROM
records WHERE ACCONT_NO = {}".format(m) c1.execute(cb)
d = c1.fetchall() data = c1.rowcount if data == 1:

print("============================================================================
====")
print("This account number already exists:") c = input("Do you want to continue y/n
- ")

print("============================================================================
====")
if c == "y":
continue else:
print("Thank you.") print("Visit again") break
else:
name = input("Enter your name: ")
passw = int(input("Enter your password: "))
ab = "INSERT INTO records(ACCONT_NO, PASSWORD, NAME) VALUES ({}, {},
'{}')".format(m, passw, name)
c1.execute(ab)

conn.commit()

print("============================================================================
====")
print("Account successfully created") print("The minimum balance is 1000")

print("============================================================================
====")
s = int(input("Enter the money to be deposited: "))

print("============================================================================
====")
sr = "UPDATE records SET CR_AMT = {} WHERE ACCONT_NO = {}".format(s, m)
c1.execute(sr)
conn.commit()
ef = "UPDATE records SET balance = CR_AMT - withdrawl WHERE ACCONT_NO =
{}".format(m)
c1.execute(ef) conn.commit()
print("Successfully deposited") print("Thank you")
print("Visit again") break

elif op == 2:
y = "y"
while y == "y":
acct = int(input("Enter your account number: "))
cb = "SELECT * FROM records WHERE ACCONT_NO = {}".format(acct) c1.execute(cb)
c1.fetchall()
data = c1.rowcount if data == 1:
pas = int(input("Enter your password: "))

print("============================================================================
====")
e = "SELECT PASSWORD FROM records WHERE ACCONT_NO = {}".format(acct) c1.execute(e)
a = c1.fetchone() d = list(a)
if pas == d[0]: print("Correct")
print("1. Depositing money") print("2. Withdrawing money") print("3. Transferring
money") print("4. Checking balance") print("5. Changing Account number")

print("============================================================================
====")
r = int(input("Enter your choice: "))

print("============================================================================
====")
if r == 1:
amt = int(input("Enter the money to be deposited: "))

print("============================================================================
====") sr = "UPDATE records SET CR_AMT = CR_AMT + {} WHERE ACCONT_NO =
{}".format(amt, acct)
c1.execute(sr) conn.commit()
ef = "UPDATE records SET balance = CR_AMT - withdrawl WHERE ACCONT_NO

= {}".format(acct)

c1.execute(ef) conn.commit()
print("Successfully deposited")
t = input("Do you want to continue y/n - ")

print("============================================================================
====")
if t == "y":
continue else:
print("Thank you") break

elif r == 2:
amt = int(input("Enter the money to withdraw: "))

print("============================================================================
====")
ah = "SELECT BALANCE FROM records WHERE ACCONT_NO = {}".format(acct) c1.execute(ah)
m = c1.fetchone() if amt > m[0]:
print("You are having less than", amt) print("Please try again")

print("============================================================================
====")
else:

{}".format(amt, acct)

{}".format(amt, acct)

sr = "UPDATE records SET balance = balance - {} WHERE ACCONT_NO = ed = "UPDATE


records SET WITHDRAWL = {} WHERE ACCONT_NO =
c1.execute(ed) c1.execute(sr) conn.commit()
print("Successfully updated")
y = input("Do you want to continue y/n - ")

print("============================================================================
====")
if y == "y":
continue else:
print("Thank you") break

elif r == 3:
act = int(input("Enter the account number to be transferred: "))

print("============================================================================
====")
cb = "SELECT * FROM records WHERE ACCONT_NO = {}".format(act) c1.execute(cb)
c1.fetchall()
data = c1.rowcount if data == 1:
print(act, "number exists")
m = int(input("Enter the money to be transferred: "))

print("============================================================================
====") ah = "SELECT BALANCE FROM records WHERE ACCONT_NO =

{}".format(acct)

c1.execute(ah)
c = c1.fetchone() if m > c[0]:
print("You are having less than", m) print("Please try again")

print("============================================================================
====")
else:
av = "UPDATE records SET balance = balance - {} WHERE ACCONT_NO = {}".format(m,
acct)
cv = "UPDATE records SET balance = balance + {} WHERE ACCONT_NO = {}".format(m,
act)
w = "UPDATE records SET withdrawl = withdrawl + {} WHERE

ACCONT_NO = {}".format(m, acct)


t = "UPDATE records SET CR_AMT = CR_AMT + {} WHERE ACCONT_NO =

{}".format(m, act)

c1.execute(av) c1.execute(cv) c1.execute(w) c1.execute(t) conn.commit()


print("Successfully transferred")
y = input("Do you want to continue y/n - ")

print("============================================================================
====")
if y == "y":
continue else:
print("Thank you") break

elif r == 4:
ma = "SELECT balance FROM records WHERE ACCONT_NO = {}".format(acct) c1.execute(ma)
k = c1.fetchone()
print("Balance in your account =", k)

print("============================================================================
====")
y = input("Do you want to continue y/n - ") if y == "y":
continue else:
print("Thank you") break

elif r == 5:
i = int(input("Enter your new account number: "))
cb = "SELECT * FROM records WHERE ACCONT_NO = {}".format(i) c1.execute(cb)
c1.fetchall()
data = c1.rowcount if data == 1:
print("This number already exists") print("Try again")
y = input("Do you want to continue y/n - ") if y == "y":
continue else:
print("Thank you") break
else:
name = input("Enter your name: ")
ar = "UPDATE records SET ACCONT_NO = {} WHERE NAME = '{}' AND
PASSWORD = {}".format(i, name, pas)
c1.execute(ar) conn.commit()
print("Your new account number is", i) break

else:
print("Wrong password")

else:
print("Your Account does not exist")

elif op == 3:
print("Exiting") c1.close()

You might also like