0% found this document useful (0 votes)
5 views

sql project.

The document outlines a project titled 'Finance Tracker' which helps users manage their expenses and budgets through various functionalities such as adding, deleting, and viewing expenses by category or date. It includes sections on requirement analysis, design, algorithms, source code, and future enhancements, with acknowledgments to contributors. The project aims to improve financial management and spending habits for individuals.

Uploaded by

nesand8a
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

sql project.

The document outlines a project titled 'Finance Tracker' which helps users manage their expenses and budgets through various functionalities such as adding, deleting, and viewing expenses by category or date. It includes sections on requirement analysis, design, algorithms, source code, and future enhancements, with acknowledgments to contributors. The project aims to improve financial management and spending habits for individuals.

Uploaded by

nesand8a
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

TABLE OF CONTENTS

S.NO CONTENTS

1. Abstract

2. Requirement analysis

→ Hardware Requirements
→ Software Requirements

3. Application

4. Design

→ Block Diagram

5. Flowchart: Program Flow

6. Algorithm

7. Source code

8. Execution Screenshots

9. Future Enhancements

10. Bibliography
AKNOWLEDGEMENT

This acknowledgement is dedicated to all the individuals who have provided


valuable resources and assistance in creating the project file. I would like to
thank Mrs.Shanmugapriya, my Computer Science teacher for the guidance
during the tenure of my project and also I would like to thank Mrs.Chitra, my
11th computer science teacher for the guidance and great teaching of the basics .
I would also like to thank my principal mam for giving this opportunity to show
my creativity and skill through this project . I thank my parents and friends who
supported me and encouraged me till the end .
ABSTRACT
FINANCE TRACKER

By:

• BHAVNA RAJAVADIVEL XII-A

The project starts with:

1 – USER MENU
2 – ADD EXPENSES
3 – DELETE EXPENSE
4 – TOTAL EXPENSE
5 – VIEW EXPENSE BY CATEGORY
6 – EXPENSE BY DATE
7 – EXPENSE BY MONTH
. 8 – SET MONTHLY BUDGET
9 – VIEW BUDGET
10 – GENERATE EXPENSE REPORT
11 - CREATE CATEGORY
12 – VIEW CATEGORIES
13 – LOGOUT

Process:

FIRSTLY, we’ll obtain the user details like user name, age, email id.

SECONDLY, we’ll obtain the users expenses according to their category


like food , entertainment etc. After adding the expenses user have the choice to
delete expenses or view total expenses.

Then user also have the choice to view expenses by category or by date or month
rage.
REQUIREMENT ANALYSIS

HARDWARE ANALYSIS

→ Laptop-BDSFLTF4-HP Laptop 15s-eq2xxx-


Window 11
→ Processor-AMD Ryzen 5 5500U with Radeon
Graphics, 64-bit operating system, x64-based
processor

SOFTWARE ANALYSIS

→ Python 3.12 64-bit


→ An Operating System
→ MS Word
→ Canva.com
APPLICATION
Individuals can use this program to keep track of their daily, weekly, or
monthly expenses, including groceries, bills, entertainment, etc.

Users can set budgets for different expense categories and compare actual
spending against budgeted amounts.

It helps user to avoid overspending and manage finances more effectively.

So user aim better spending habits and improve their financial.


BlOCK DIAGRAM

USER MENU

AUTHENTICATION

(Register/login)

EXPENSE MANAGEMENT

(Add/view/Delete)

BUDGET MANAGEMENT

(Set/view)

GENERATE REPORT

DATA STORAGE
ALGORITHM
1. Connect to SQL database
2. Display the statements, welcome to Finance Tracker
3. Ask the user to enter the choice:
Finance Tracker Menu:
1 – USER MENU
2 – ADD EXPENSES
3 – DELETE EXPENSE
4 – TOTAL EXPENSE
5 – VIEW EXPENSE BY CATEGORY
6 – EXPENSE BY DATE
7 – EXPENSE BY MONTH
8 – SET MONTHLY BUDGET
9 – VIEW BUDGET
10 – GENERATE EXPENSE REPORT
11 – CREATE CATEGORY
12 – VIEW CATEGORIES
13 – LOGOUT
4. If the user enters 1 as choice,ask for name, password and login
5. If user enters 2 as choice, Add expense to the database
6. If the user enters 3 as choice, Display Total Expenses.
7. If the user enters 4 as choice, Ask for the category name the user wants
to view and the total expense of the category will be displayed.
8. If the user enters choice 5 ,Ask for the date(YYYY/MM/DD) for which
the user wants the expense.
9. If the user enters 6 as choice, Ask for the month for which the user wants
the expense.
10.If the user enters 7 as choice, Display “Exiting Finance Tracker”.
11.If the user enters 8or9 as choice, Add or display budget
12.If the user enter 10 as choice, display the report of budget
13. If the user enter 11 or 12 as choice create or display the category
14.if user enter 13 as choice logout and return to main menu
SOURCE CODE
import mysql.connector as m

def connect():

'_Connect to MySQL database_ '

conn=m.connect(host='localhost',database='FINANCE_TRACkER',user='root',
password='bhavna181007')

if conn.is_connected():

print("Connected to MySQL Database")

return conn

a=connect()

def register_user(conn):

'_Register a new user_'

user=input("Enter a username: ")

password=input("Enter a password: ")

cursor = conn.cursor()

try:

cursor.execute("INSERT INTO USER(USERNAME,PASSWORD)


VALUES (%s,%s)",(user,password))

conn.commit()

print("User registered successfully.")

finally:

cursor.close()

def authenticate_user(conn):

""" Authenticate an existing user """


username = input("Enter your username: ")

password = input("Enter your password: ")

cursor = conn.cursor()

cursor.execute("SELECT USERNAME, password FROM USER WHERE


username = %s", (username,))

user = cursor.fetchone()

if user and user[1]==password:

print("Login successful!")

return user[0]

else:

print("Invalid username or password.")

cursor.close()

return None

def add_expense(conn,user_id):

'_Create a new expense_'

exp_id=input('Enter the expenseid :')

date=input("Enter date (YYYY-MM-DD): ")

amt=float(input("Enter amount: "))

desc=input("Enter description: ")

cat_id=input("Enter category ID (or leave blank): ")

cursor=conn.cursor()

cursor.execute("INSERT INTO expenses(user_id,expense_id,date, amount,


description, category_id) VALUES (%s, %s, %s, %s, %s,%s)",(user_id,exp_id,
date, amt, desc, cat_id))

conn.commit()
print("Expense added successfully.")

cursor.close()

def delete_expense(conn,user_id):

'_Delete an expense_'

expense_id =int(input("Enter expense ID to delete: "))

cursor=conn.cursor()

cursor.execute("DELETE FROM expenses WHERE expense_id = %s AND


user_id = %s", (expense_id, user_id))

conn.commit()

print("Expense deleted successfully.")

def total_expense(conn,user_id):

'_Calculate total expenses for a user_'

cursor = conn.cursor()

cursor.execute("SELECT SUM(amount) FROM expenses WHERE user_id =


%s", (user_id,))

total = cursor.fetchone()

print("Total expenses:",total[0])

def view_expenses_by_category(conn,user_id):

'__View expenses by category__'

category_id = input("Enter category ID: ")

cursor = conn.cursor()

cursor.execute("SELECT * FROM expenses WHERE user_id = %s AND


category_id = %s", (user_id, category_id))

exp=cursor.fetchall()

print("ID | Date | Amount | Description")


print("---|------------|--------|-------------")

for e in exp:

print(f"{e[0]} | {e[2]} | {e[3]:.2f} | {e[4]}")

if not exp:

print("No expenses found for this category.")

else:

print("Total expenses in this category:", len(exp))

def view_expenses_by_date(conn,user_id):

'_View expenses by a specific date_'

date=input("Enter date(YYYY-MM-DD):")

cursor=conn.cursor()

cursor.execute("SELECT * FROM expenses WHERE user_id = %s AND


date = %s", (user_id, date))

exp = cursor.fetchall()

print("ID | Amount | Description")

print("---|--------|-------------")

for e in exp:

print(f"{e[0]} | {e[3]:.2f} | {e[4]}")

print("Total expenses on this date:", len(exp))

def view_expenses_by_month(conn,user_id):

'_View expenses for a specific month_'

month=input("Enter month(YYYY-MM): ")

cursor = conn.cursor()

cursor.execute("""SELECT * FROM expenses WHERE user_id = %s AND


DATE_FORMAT(date, '%Y-%m') = %s""", (user_id, month))
exp= cursor.fetchall()

print("ID | Date | Amount | Description")

print("---|------------|--------|-------------")

for e in exp:

print(f"{e[0]} | {e[2]} | {e[3]:.2f} | {e[4]}")

print("Total expenses for the month:", len(exp))

def create_category(conn):

'__Create a new expense category.__'

category_name = input("Enter the new category name: ")

cat_id=input("Enter the category id: ")

cursor = conn.cursor()

try:

cursor.execute("INSERT INTO categories (category_name,category_id)


VALUES (%s,%s)", (category_name,cat_id))

conn.commit()

print("Category created successfully.")

finally:

cursor.close()

def view_categories(conn):

'__View all expense categories__'

cursor=conn.cursor()

cursor.execute("SELECT * FROM categories")

cat=cursor.fetchall()

cursor.close()
print("Categories:")

for c in cat:

print(f"Name: {c[0]},ID: {c[1]}")

def set_monthly_budget(conn, user_id):

'__Set a monthly budget for the user__'

budget=float(input("Enter your monthly budget: "))

cursor=conn.cursor()

try:

cursor.execute("UPDATE USER SET monthly_budget = %s WHERE


USERNAME = %s", (budget, user_id))

conn.commit()

print("Monthly budget set successfully.")

finally:

cursor.close()

def te(conn, user_id):

'__Calculate total expenses for a specific user__'

cursor = conn.cursor()

cursor.execute("SELECT SUM(amount) FROM expenses WHERE user_id =


%s", (user_id,))

t= cursor.fetchone()

if t[0] is not None:

return t[0]

else:

return 0

def view_budget_status(conn, user_id):


"""View the user's budget status."""

cursor = conn.cursor()

cursor.execute("SELECT monthly_budget FROM USER WHERE


USERNAME = %s", (user_id,))

budget = cursor.fetchone()

if budget:

global te

te=te(a,user_id)

rb= budget[0] - te

print(f"Monthly Budget: {budget[0]}, Total Expenses: {te}, Remaining


Budget: {rb}")

else:

print("No budget")

def generate_report(conn, user_id):

'__Generate an expense report__'

sd = input("Enter start date (YYYY-MM-DD): ")

ed = input("Enter end date (YYYY-MM-DD): ")

cursor = conn.cursor()

cursor.execute("SELECT * FROM expenses WHERE user_id = %s AND


date BETWEEN %s AND %s", (user_id, sd,ed))

exp=cursor.fetchall()

cursor.close()

print("User_ID | Expense_ID | Date | Amount | Description | Category ID")

print("--------|------------|--------|--------|-------------|------------")

for e in exp:
print(f"{e[0]} | {e[1]} | {e[2]} | {e[3]:.2f} | {e[4]} | {e[5]} ")

print("Total expenses in the report period:", len(exp))

def main():

while True:

print("*** WELCOME TO FINANCE TRACKER ***")

print("1. Register")

print("2. Login")

print("3. Exit")

choice = input("Choose an option: ")

if choice == '1':

register_user(a)

elif choice == '2':

user_id = authenticate_user(a)

if user_id is None:

continue

while True:

print("\nUser Menu")

print("1. Add Expense")

print("2. Delete Expense")

print("3. Total Expense")

print("4. View Expense by Category")

print("5. View Expense by Date")

print("6. View Expense by Month")

print("7. Set Monthly Budget")


print("8. View Budget Status")

print("9. Generate Expense Report")

print("10.Create Category ")

print("11.View Categories")

print("12. Logout")

user_choice = input("Choose an option: ")

if user_choice == '1':

add_expense(a, user_id)

elif user_choice == '2':

delete_expense(a, user_id)

elif user_choice == '3':

total_expense(a, user_id)

elif user_choice == '4':

view_expenses_by_category(a, user_id)

elif user_choice == '5':

view_expenses_by_date(a, user_id)

elif user_choice == '6':

view_expenses_by_month(a, user_id)

elif user_choice == '7':

set_monthly_budget(a, user_id)

elif user_choice == '8':

view_budget_status(a, user_id)

elif user_choice == '9':

generate_report(a, user_id)
elif user_choice == '10':

create_category(a)

elif user_choice == '11':

view_categories(a)

elif user_choice == '12':

print("Logged out.")

break

else:

print("Invalid choice. Please try again.")

elif choice == '3':

break

else:

print("Invalid choice. Please try again.")

conn.close()

if __name__ == '__main__':

main()
OUTPUT SCREENSHOT
REGISTRATION:

LOGIN:
ADD EXPENSES:

DEETE EXPENSE:
TOTAL EXPENSE:

VIEW EXPENSE BY CATEGORY:


VIEW EXPENSE BY DATE:

VIEW EXPENSE BY MONTH:


SET MONTHLY BUDGET:

VIEW BUDGET STATUS:


GENERATE EXPENSE REPORT:

CREATE CATEGORY:
VIEW CATEGORIES:

LOGOUT:
FLOW CHART
FUTURE ENHANCEMENT

➢ Implementing AI to help users to set realistic saving or spending goals


➢ Support multiple currencies for users who travel or have international
accounts.
➢ Integration with Financial APIs:
Connect with banking APIs to automate the tracking of transactions and
balances.
BIBLIOGRAPHY

➢ NCERT 11th and 12th book to refer basic functions of python and MySQL
➢ SUMITA ARORA 11th and 12th
➢ Geeksforgeeks Website, for deep understanding of working of functions
in python
Link:
https://www.geeksforgeeks.org/
➢ Chatgpt ,to refer and clear doubts
➢ W3school website, to refer about MySQL connector and python
Link:
https://www.w3schools.com/#gsc.tab=0

You might also like