Ebanking
Ebanking
This document contains the Python and SQL code for an E-Banking System. It demonstrates how to use
Python with MySQL to perform banking operations such as creating accounts, depositing, withdrawing,
transferring money, checking balances, and deleting accounts. The code is divided into two parts:
Python code and SQL code. The Python code communicates with MySQL to perform the required
operations. Below are the details and examples of using the banking system.
db = mysql.connector.connect(
cursor = db.cursor()
query = "INSERT INTO accounts (name, pin, balance) VALUES (%s, %s, %s)"
cursor.execute(query, values)
db.commit()
print(f"Account created successfully! Account Number: {cursor.lastrowid}")
db.commit()
balance = cursor.fetchone()
db.commit()
else:
print("Insufficient balance!")
balance = cursor.fetchone()
if balance and balance[0] >= amount:
try:
db.start_transaction()
db.commit()
except:
db.rollback()
print("Transfer failed!")
else:
print("Insufficient balance!")
def check_balance(account_number):
result = cursor.fetchone()
if result:
else:
def delete_account(account_number):
query = "DELETE FROM accounts WHERE account_number = %s"
cursor.execute(query, (account_number,))
db.commit()
if __name__ == "__main__":
while True:
print("7. Exit")
if choice == '1':
deposit(account_number, amount)
withdraw(account_number, amount)
check_balance(account_number)
delete_account(account_number)
break
else:
cursor.close()
db.close()
SAMPLE CODE
CREATING ACCOUNT
Checking Balance