Nihal Ashik - PythonSQL Program of The BOISSS PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

COMPUTER SCIENCE

PROJECT
Project: SMART BANK

Name: Nihal Ashik


Class: 12 J
Birla Public School 2023-24
Acknowledgement
I would like to express my special thanks to our
acting principal Mrs Radika Rele for providing me
with all the facilities which were necessary for my
project.
I would also like to extend my gratitude to my
computer science teacher Mrs.Arshi Habiba who
gave me a golden opportunity to do this project and
also provide support in completing my project by
which I was able to explore the infinite possibilities
out in the world.
I would also like to thank my friends for helping me
with the project to ensure its proper functioning with
no mistakes at all circumstances.
Project specifications
The "Bank Transaction Management System" is a Python-
based application that facilitates basic banking
operations, such as creating accounts, depositing money,
withdrawing money, and displaying account details.
The application interacts with a MySQL database to store
and manage account holder information and transaction
history. This project aims to provide users with a simple
and user-friendly interface to perform essential banking
tasks.
The significance of this project lies in its potential to
revolutionize the way individuals and businesses interact
with their financial resources. By automating banking
processes and centralizing data storage, the application
improves efficiency and data accuracy, reducing the
likelihood of errors associated with manual record-
keeping.
Moreover, it enhances customer satisfaction by providing
timely access to account information and facilitating
transactions, contributing to a more seamless banking
experience

1
Software specifications
Software specifications Python is an interpreted, high-level and
general- purpose programming language. python's design
philosophy emphasizes code readability with its notable use of
significant whitespace.
Its language constructs and object-oriented approach aim to help
programmers write clear, logical code for small and large-scale
projects. MySQL is an open source relational database
management system(RDBMS) with a client-server model.
RDBMS is a software or service used to create and manage
databases based on a relational model.in addition to relational
databases and SQL, an RDBMS like MySQL works with an operating
system to implement a relational databases in a computer's
storage system, manages users, allows for network access and
facilitates testing database integrity and creation of backups.
Python and MySQL are being connected using the MySQL
connector, one module among the various included in the vast
library of modules available in the python database.

2
Index
Srno Content Page no
1 Acknowledgement 1
2 Project specification 2
3 Software specification 3
4 Application of Function 5
5 Python code 6-9
6 SQL Tables 9
7 Output 10
8 Bibliography 12

3
Application of Functions
mysql.connector.connect(): This function is used to create a connection to a MySQL
database. It takes in several parameters, such as the host, user, and password, and
returns a MySQLConnection object.
cursor(): This method is called on a MySQLConnection object and returns a Cursor
object. A Cursor object is used to interact with a MySQL database.
execute(): This method is called on a Cursor object and is used to execute a MySQL
query. It takes a single parameter, which is the MySQL query to be executed.
commit(): This method is called on a MySQLConnection object and is used to commit
any changes made to the database. This is necessary to ensure that changes made to
the database are permanent.
input(): This function is used to take user input. It prompts the user to enter a value and
returns the input as a string.
str(): This function is used to convert a value to a string.
int(): This function is used to convert a value to an integer.
break: This keyword is used to break out of a loop.
if...elif...else: This is a conditional statement used to execute different blocks of code
depending on the condition. The if block is executed if the condition is true, the elif block
is executed if the previous condition is false and the current condition is true, and the
else block is executed if all the previous conditions are false.
for : This is a loop that is used to iterate over a sequence of values. In this code, it is used
to iterate over the result of a MySQL query and print the values.
primary key: This is a column or group of columns in a database table that uniquely
identifies each row. In this code, the “acno” column in the “bank_master” table is set as
the primary key, which means that each account number can only appear once in the
table.

4
Python code
print("BANK TRANSACTION")
#creating database
import mysql.connector
mydb=mysql.connector.connect (host="localhost",user="root",
password="plsgivefullmarks",database="bankofworld")
mycursor=mydb.cursor()
mycursor.execute("create table mastertable (account_number CHAR(15),
account_holder_name VARCHAR(50), account_city VARCHAR(50), balance
DECIMAL(10, 2));")
mycursor.execute("create table trxtable (account_number varchar(20),
amount int(9),dot date, trx_type VARCHAR(30));")
mydb.commit()
while(True):

print("1=Create account")
print("2=Deposit money")
print("3=Withdraw money")
print("4=Display account")
print("5=Exit")
ch=int(input("Enter your choice:"))

#PROCEDURE FOR CREATING A NEW ACCOUNT OF THE APPLICANT


if(ch==1):
print("All information prompted are mandatory to be filled")
acno=str(input("Enter account number:"))
name=input("Enter name(limit 35 characters):")
type=str(input("Enter city:"))
balance=0

5
mycursor.execute("insert into mastertable
values('"+acno+"','"+name+"','"+type+"','"+str(balance)+"')")
mydb.commit()
print("Account is successfully created!!!")

#PROCEDURE FOR UPDATIONG DETAILS AFTER THE DEPOSITION OF MONEY BY THE


APPLICANT
elif(ch==2):
acno=str(input("Enter account number:"))
dp=int(input("Enter amount to be deposited:"))
dot=str(input("Enter date of Transaction: YYYY-MM-DD "))
tp="Deposit"
mycursor.execute("insert into trxtable
values('"+acno+"','"+str(dp)+"','"+dot+"','"+tp+"')")
mycursor.execute("update mastertable set
balance=balance+'"+str(dp)+"' where account_number='"+acno+"'")
mydb.commit()
print("money has been deposited successully!!!")
#PROCEDURE FOR UPDATING THE DETAILS OF ACCOUNT AFTER THE WITHDRAWL OF
MONEY BY THE APPLICANT

elif(ch==3):
acno=str(input("Enter account number:"))
wd=int(input("Enter amount to be withdrawn:"))
dot=str(input("enter date of transaction: YYYY-MM-DD "))
tp="Withdraw"
mycursor.execute("insert into trxtable
values('"+acno+"','"+str(dp)+"','"+dot+"','"+tp+"')")
mycursor.execute("update mastertable set
balance=balance-'"+str(wd)+"' where account_number='"+acno+"'")
mydb.commit()

6
#PROCEDURE FOR DISPLAYING THE ACCOUNT OF THE ACCOUNT HOLDER AFTER
HE/SHE ENTERS HIS/HER ACCOUNT NUMBER
elif(ch==4):
acno=str(input("Enter account number:"))
mycursor.execute("select * from mastertable where
account_number='"+acno+"'")
for i in mycursor:
print(i)
else:
Break

7
Output of SQL table

8
Input Terminal

BANK TRANSACTION
1=Create account
2=Deposit money
3=Withdraw money
4=Display account
5=Exit
Enter your choice:1
All information prompted are mandatory to be filled
Enter account number:2001
Enter name(limit 35 characters):Shailesh
Enter city:Doha
Account is successfully created!!!
1=Create account
2=Deposit money
3=Withdraw money
4=Display account
5=Exit
Enter your choice:1
All information prompted are mandatory to be filled
Enter account number:2002
Enter name(limit 35 characters):Qaizar
Enter city:Madrid
Account is successfully created!!!
1=Create account
2=Deposit money
3=Withdraw money
4=Display account
5=Exit
Enter your choice:1
All information prompted are mandatory to be filled
Enter account number:2003

9
Enter name(limit 35 characters):Nihal
Enter city:Argentina
Account is successfully created!!!
1=Create account
2=Deposit money
3=Withdraw money
4=Display account
5=Exit
Enter your choice:2
Enter account number:2001
Enter amount to be deposited:3000
Enter date of Transaction: YYYY-MM-DD 2023-02-23
money has been deposited successully!!!
1=Create account
2=Deposit money
3=Withdraw money
4=Display account
5=Exit
Enter your choice:2
Enter account number:2002
Enter amount to be deposited:23500
Enter date of Transaction: YYYY-MM-DD 2022-10-31
money has been deposited successully!!!
1=Create account
2=Deposit money
3=Withdraw money
4=Display account
5=Exit
Enter your choice:2
Enter account number:2003
Enter amount to be deposited:7000
Enter date of Transaction: YYYY-MM-DD 2023-08-23
money has been deposited successully!!!
1=Create account
2=Deposit money
3=Withdraw money
4=Display account
5=Exit

10
Enter your choice:4
Enter account number:2003
('2003', 'Nihal', 'Argentina', Decimal('7000.00'))

Bibliography
MySQLDocumentation.(n.d.).MySQL 8.0 Reference Manual.
https://dev.mysql.com/doc/refman/8.0/en/
PythonSoftwareFoundation.(2021).Built-in Functions: input().
https://docs.python.org/3/library/functions.html#input
MySQLDocumentation.(n.d.).DROP DATABASE Statement.
https://dev.mysql.com/doc/refman/8.0/en/drop-database.html

11

You might also like