Python Projects for Class 12 CBSE Students with Output-Banking System


Python project for class 12 CBSE students- Banking Management System Using MySQL database. The whole project is divided into 4 major parts.

  1. Opening a New Account in Bank
  2. Cash Withdrawal from the Account
  3. Cash Deposit in the account
  4. Search Options – Search Customer Database as well as Transaction database on different conditions
  5. Report Options – Different types of reports for Banking purposes.

Data Tables used in Banking Project

mysql> desc customer;
+-----------+--------------+------+-----+---------+----------------+
| Field     | Type         | Null | Key | Default | Extra          |
+-----------+--------------+------+-----+---------+----------------+
| acno      | int(11)      | NO   | PRI | NULL    | auto_increment |
| name      | char(30)     | YES  |     | NULL    |                |
| address   | varchar(100) | YES  |     | NULL    |                |
| phone     | varchar(15)  | YES  |     | NULL    |                |
| email     | varchar(80)  | YES  |     | NULL    |                |
| aadhar_no | varchar(20)  | YES  |     | NULL    |                |
| acc_type  | varchar(20)  | YES  |     | NULL    |                |
| status    | char(15)     | YES  |     | NULL    |                |
| balance   | float(15,2)  | YES  |     | NULL    |                |
+-----------+--------------+------+-----+---------+----------------+
9 rows in set (0.05 sec)

mysql> desc transaction;
+--------+----------+------+-----+---------+----------------+
| Field  | Type     | Null | Key | Default | Extra          |
+--------+----------+------+-----+---------+----------------+
| tid    | int(11)  | NO   | PRI | NULL    | auto_increment |
| dot    | date     | YES  |     | NULL    |                |
| amount | int(10)  | YES  |     | NULL    |                |
| type   | char(20) | YES  |     | NULL    |                |
| acno   | int(10)  | YES  |     | NULL    |                |
+--------+----------+------+-----+---------+----------------+
5 rows in set (0.02 sec)

Sample Tables with records

mysql> select * from customer;
+------+---------------+-------------------+-------------+------------------------+----------------+----------+--------+----------+
| acno | name          | address           | phone       | email                  | aadhar_no      | acc_type | status | balance  |
+------+---------------+-------------------+-------------+------------------------+----------------+----------+--------+----------+
|    1 | rakesh kumar  | cf-4 surya nagar  | 987181818   | support@cbsetoday.com  | 1234-1243-4545 | saving   | active | 17200.00 |
|    2 | rajbeer singh | A-75-B Brij vihar | 96734344318 | raju@cbsetoday.com     | 4545-1243-4545 | current  | active | 15500.00 |
|    3 | archana       | cf04              | 4545456     | archana@bianrynote.com | 1234-5656-4545 | saving   | active | 10000.00 |
|    4 | ashutosh      | d-100 brij vihar  | 1122334455  | ashu@gmail.com         | 1124-5656-6576 | saving   | close  | 56000.00 |
|    5 | raman singh   | e-40 radha bihar  | 3344556677  | raman@yahoo.com        | 4455-5656-4545 | saving   | close  | 20000.00 |
|    6 | sam           | f-12 surya nagar  | 1234        | sam@gmail.com          | 1234-4556-5656 | saving   | active | 22000.00 |
|    7 | ramji         | f-123 ram vihar   | 9988229922  | ramji@gmail.com        | 1234-4556-4565 | saving   | active | 20000.00 |
+------+---------------+-------------------+-------------+------------------------+----------------+----------+--------+----------+
mysql> select * from transaction;
+-----+------------+--------+----------+------+
| tid | dot        | amount | type     | acno |
+-----+------------+--------+----------+------+
|   1 | 2020-10-16 |   2000 | deposit  |    1 |
|   2 | 2020-10-15 |   2000 | deposit  |    2 |
|   3 | 2020-10-18 |   1200 | withdraw |    1 |
|   4 | NULL       |   2000 | deposit  |    1 |
|   5 | 2020-11-30 |    200 | deposit  |    1 |
|   6 | 2020-11-30 |   2000 | withdraw |    1 |
|   7 | 2020-11-30 |    200 | withdraw |    1 |
|   8 | 2020-12-01 |   2000 | deposit  |    6 |
|   9 | 2020-12-01 |   5000 | deposit  |    1 |
|  10 | 2020-12-01 |   2500 | deposit  |    2 |
|  11 | 2020-12-01 |   2000 | withdraw |    2 |
|  12 | 2020-12-01 |   5000 | deposit  |    2 |
+-----+------------+--------+----------+------+

Source code

# Project Name          : Banking System
# Made by               : rakesh kumar
# session               : your session name
# roll  no              : your roll no

import mysql.connector
from datetime import date

def clear():
  for _ in range(65):
     print()

def customer_record():
  conn = mysql.connector.connect(
      host='localhost', database='bankproject', user='root', password='')
  cursor = conn.cursor()
  sql ="select * from customer;"
  cursor.execute(sql)
  results = cursor.fetchall()
  clear()
  print('Customer Records')
  print('-'*120)
  for result in results:
    print(result[0], result[1], result[2], result[3], result[4], result[5],result[6], result[7], result[8])
  print('-'*120)
  conn.close()
  wait = input('\n\n\n Press any key to continue....')

def account_status(acno):
  conn = mysql.connector.connect(
      host='localhost', database='bankproject', user='root', password='')
  cursor = conn.cursor()
  sql ="select status,balance from customer where acno ='"+acno+"'"
  result = cursor.execute(sql)
  result = cursor.fetchone()
  conn.close()
  return result

def deposit_amount():
    conn = mysql.connector.connect(
        host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
    clear()
    acno = input('Enter account No :')
    amount = input('Enter amount :')
    today = date.today()
    result = account_status(acno)
    if result [0]== 'active':
      sql1 ="update customer set balance = balance+"+amount + ' where acno = '+acno+' and status="active";'
      sql2 = 'insert into transaction(amount,type,acno,dot) values(' + amount +',"deposit",'+acno+',"'+str(today)+'");'
      cursor.execute(sql2)
      cursor.execute(sql1)
      #print(sql1)
      #print(sql2)
      print('\n\namount deposited')

    else:
      print('\n\nClosed or Suspended Account....')
    
    wait= input('\n\n\n Press any key to continue....')
    conn.close()


def withdraw_amount():
    conn = mysql.connector.connect(
        host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
    clear()
    acno = input('Enter account No :')
    amount = input('Enter amount :')
    today = date.today()
    result = account_status(acno)
    if result[0] == 'active' and int(result[1])>=int(amount):
      sql1 = "update customer set balance = balance-" + \
          amount + ' where acno = '+acno+' and status="active";'
      sql2 = 'insert into transaction(amount,type,acno,dot) values(' + \
          amount + ',"withdraw",'+acno+',"'+str(today)+'");'

      cursor.execute(sql2)
      cursor.execute(sql1)
      #print(sql1)
      #print(sql2)
      print('\n\namount Withdrawn')

    else:
      print('\n\nClosed or Suspended Account.Or Insufficient amount')

    wait = input('\n\n\n Press any key to continue....')
    conn.close()

def transaction_menu():
    while True:
      clear()
      print(' Trasaction Menu')
      print("\n1.  Deposit Amount")
      print('\n2.  WithDraw Amount')
      print('\n3.  Back to Main Menu')
      print('\n\n')
      choice = int(input('Enter your choice ...: '))
      if choice == 1:
        deposit_amount()
      if choice == 2:
        withdraw_amount()
      if choice == 3:
        break

def search_menu():
    conn = mysql.connector.connect(
       host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
    while True:
      clear()
      print(' Search Menu')
      print("\n1.  Account No")
      print('\n2.  Aadhar Card')
      print('\n3.  Phone No')
      print('\n4.  Email')
      print('\n5.  Names')
      print('\n6.  Back to Main Menu')
      print('\n\n')
      choice = int(input('Enter your choice ...: '))
      field_name=''
   
      if choice == 1:
        field_name ='acno'
  
      if choice == 2:
        field_name ='aadhar_no'
   
      if choice == 3:
        field_name = 'phone'
      
      if choice == 4:
        field_name = 'email'

      if choice == 5:
        field_name = 'name'
      
      if choice == 6:
        break
      msg ='Enter '+field_name+': '
      value = input(msg)
      if field_name=='acno':
        sql = 'select * from customer where '+field_name + ' = '+value+';'
      else:
        sql = 'select * from customer where '+field_name +' like "%'+value+'%";'
      #print(sql)
      cursor.execute(sql)
      records = cursor.fetchall()
      n = len(records)
      clear()
      print('Search Result for ', field_name, ' ',value)
      print('-'*80)
      for record in records:
       print(record[0], record[1], record[2], record[3],
             record[4], record[5], record[6], record[7], record[8])
      if(n <= 0):
        print(field_name, ' ', value, ' does not exist')
      wait = input('\n\n\n Press any key to continue....')

    conn.close()
    wait=input('\n\n\n Press any key to continue....')

def daily_report():
   clear()
   
   conn = mysql.connector.connect(
       host='localhost', database='bankproject', user='root', password='')
   today = date.today()
   cursor = conn.cursor()
   sql = 'select tid,dot,amount,type,acno from transaction t where dot="'+ str(today)+'";'
   cursor.execute(sql)
   records = cursor.fetchall()
   clear()
   print('Daily Report :',today)
   print('-'*120)
   for record in records:
       print(record[0], record[1], record[2], record[3], record[4])
   print('-'*120)

   conn.close()
   wait = input('\n\n\n Press any key to continue....')


def monthly_report():
   clear()

   conn = mysql.connector.connect(
       host='localhost', database='bankproject', user='root', password='')
   today = date.today()
   cursor = conn.cursor()
   sql = 'select tid,dot,amount,type,acno from transaction t where month(dot)="' + \
       str(today).split('-')[1]+'";'
   cursor.execute(sql)
   records = cursor.fetchall()
   clear()
   print(sql)
   print('Monthly Report :', str(today).split(
       '-')[1], '-,', str(today).split('-')[0])
   print('-'*120)
   for record in records:
       print(record[0], record[1], record[2], record[3], record[4])
   print('-'*120)

   conn.close()
   wait = input('\n\n\n Press any key to continue....')

def account_details():
    clear()
    acno = input('Enter account no :')
    conn = mysql.connector.connect(
        host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
    sql ='select * from customer where acno ='+acno+';'
    sql1 = 'select tid,dot,amount,type from transaction t where t.acno='+acno+';'
    cursor.execute(sql)
    result = cursor.fetchone()
    clear()
    print('Account Details')
    print('-'*120)
    print('Account No :',result[0])
    print('Customer Name :',result[1])
    print('Address :',result[2])
    print('Phone NO :',result[3])
    print('Email ID :',result[4])
    print('Aadhar No :',result[5])
    print('Account Type :',result[6])
    print('Account Status :',result[7])
    print('Current Balance :',result[8])
    print('-'*120)
    cursor.execute(sql1)
    results = cursor.fetchall()
    for result in results:
        print(result[0], result[1], result[2], result[3])

    conn.close()
    wait=input('\n\n\nPress any key to continue.....')

def report_menu():
    while True:
      clear()
      print(' Report Menu')
      print("\n1.  Daily Report")
      print('\n2.  Monthly Report')
      print('\n3.  Account Details')
      print('\n4.  Customer Records')
      print('\n5.  Back to Main Menu')
      print('\n\n')
      choice = int(input('Enter your choice ...: '))
      if choice == 1:
        daily_report()
      if choice == 2:
        monthly_report()
      if choice == 3:
        account_details()
      if choice == 4:
        customer_record()
      if choice == 5:
        break

def add_account():
    conn = mysql.connector.connect(
        host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
   
    name = input('Enter Name :')
    addr = input('Enter address ')
    phone = input('Enter Phone no :')
    email = input('Enter Email :')
    aadhar = input('Enter AAdhar no :')
    actype = input('Account Type (saving/current ) :')
    balance = input('Enter opening balance :')
    sql = 'insert into customer(name,address,phone,email,aadhar_no,acc_type,balance,status) values ( "' + name +'","'+ addr+'","'+phone+'","'+email+'","'+aadhar+'","'+actype+'",'+balance+',"active" );'
    #print(sql)
    cursor.execute(sql)
    conn.close()
    print('\n\nNew customer added successfully')
    wait= input('\n\n\n Press any key to continue....')


def modify_account():
    conn = mysql.connector.connect(
        host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
    clear()
    acno = input('Enter customer Account No :')
    print('Modify screen ')
    print('\n 1.  Customer Name')
    print('\n 2.  Customer Address')
    print('\n 3.  Customer Phone No')
    print('\n 4.  Customer Email ID')
    choice = int(input('What do you want to change ? '))
    new_data  = input('Enter New value :')
    field_name=''
    if choice == 1:
       field_name ='name'
    if choice == 2:
       field_name = 'address'
    if choice == 3:
       field_name = 'phone'
    if choice == 4:
       field_name = 'email'
    sql ='update customer set ' + field_name + '="'+ new_data +'" where acno='+acno+';' 
    #print(sql)
    cursor.execute(sql)
    print('\n\nCustomer Information modified..')
    wait = input('\n\n\n Press any key to continue....')

def close_account():
    conn = mysql.connector.connect(
        host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
    clear()
    acno = input('Enter customer Account No :')
    sql ='update customer set status="close" where acno ='+acno+';'
    cursor.execute(sql)
    print('\n\nAccount closed')
    wait = input('\n\n\n Press any key to continue....')


def activate_account():
    conn = mysql.connector.connect(
        host='localhost', database='bankproject', user='root', password='')
    cursor = conn.cursor()
    clear()
    acno = input('Enter customer Account No :')
    sql = 'update customer set status="active" where acno ='+acno+';'
    cursor.execute(sql)
    print('\n\nAccount Activated')
    wait = input('\n\n\n Press any key to continue....')

def main_menu():
    while True:
      clear()
      print(' Main Menu')
      print("\n1.  Add Account")
      print('\n2.  Modify Account')
      print('\n3.  Close Account')
      print('\n4.  Activate Account')
      print('\n5.  Transactio Menu')
      print('\n6.  Search Menu')
      print('\n7.  Report Menu')
      print('\n8.  Close application')
      print('\n\n')
      choice = int(input('Enter your choice ...: '))
      if choice == 1:
        add_account()
      if choice == 2:
        modify_account()
      if choice == 3:
        close_account()

      if choice == 4:
        activate_account()

      if choice ==5 :
        transaction_menu()
      if choice ==6 :
        search_menu()
      if choice == 7:
        report_menu()
      if choice ==8:
        break

if __name__ == "__main__":
    main_menu()

Download Source code

How to Run the Banking System Python Project

  1. Unzip Source code in a Folder. The folder will contain two files  1. BankProject.Py  2. MySQL backup file
  2. Restore MySQL backup file in your database
  3. Make an appropriate adjustment in MySQL.connection
  4. use your IDE/IDLE to open the BankProject.py file and run it

Sample output of the above Python Code.

Conclusion

Python project ideas for students. There is a list of new Python Project for class 12 ideas that you can explore for your next project. in this list we have covered more than 50 python project ideas including Django, WebScrapping, Desktop applications as well as some automation.

 

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to contribute@cbsetoday.com See your article appearing on the cbsetoday.com main page and help other students/teachers.