sql project.
sql project.
S.NO CONTENTS
1. Abstract
2. Requirement analysis
→ Hardware Requirements
→ Software Requirements
3. Application
4. Design
→ Block Diagram
6. Algorithm
7. Source code
8. Execution Screenshots
9. Future Enhancements
10. Bibliography
AKNOWLEDGEMENT
By:
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.
Then user also have the choice to view expenses by category or by date or month
rage.
REQUIREMENT ANALYSIS
HARDWARE ANALYSIS
SOFTWARE ANALYSIS
Users can set budgets for different expense categories and compare actual
spending against budgeted amounts.
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():
conn=m.connect(host='localhost',database='FINANCE_TRACkER',user='root',
password='bhavna181007')
if conn.is_connected():
return conn
a=connect()
def register_user(conn):
cursor = conn.cursor()
try:
conn.commit()
finally:
cursor.close()
def authenticate_user(conn):
cursor = conn.cursor()
user = cursor.fetchone()
print("Login successful!")
return user[0]
else:
cursor.close()
return None
def add_expense(conn,user_id):
cursor=conn.cursor()
conn.commit()
print("Expense added successfully.")
cursor.close()
def delete_expense(conn,user_id):
'_Delete an expense_'
cursor=conn.cursor()
conn.commit()
def total_expense(conn,user_id):
cursor = conn.cursor()
total = cursor.fetchone()
print("Total expenses:",total[0])
def view_expenses_by_category(conn,user_id):
cursor = conn.cursor()
exp=cursor.fetchall()
for e in exp:
if not exp:
else:
def view_expenses_by_date(conn,user_id):
date=input("Enter date(YYYY-MM-DD):")
cursor=conn.cursor()
exp = cursor.fetchall()
print("---|--------|-------------")
for e in exp:
def view_expenses_by_month(conn,user_id):
cursor = conn.cursor()
print("---|------------|--------|-------------")
for e in exp:
def create_category(conn):
cursor = conn.cursor()
try:
conn.commit()
finally:
cursor.close()
def view_categories(conn):
cursor=conn.cursor()
cat=cursor.fetchall()
cursor.close()
print("Categories:")
for c in cat:
cursor=conn.cursor()
try:
conn.commit()
finally:
cursor.close()
cursor = conn.cursor()
t= cursor.fetchone()
return t[0]
else:
return 0
cursor = conn.cursor()
budget = cursor.fetchone()
if budget:
global te
te=te(a,user_id)
rb= budget[0] - te
else:
print("No budget")
cursor = conn.cursor()
exp=cursor.fetchall()
cursor.close()
print("--------|------------|--------|--------|-------------|------------")
for e in exp:
print(f"{e[0]} | {e[1]} | {e[2]} | {e[3]:.2f} | {e[4]} | {e[5]} ")
def main():
while True:
print("1. Register")
print("2. Login")
print("3. Exit")
if choice == '1':
register_user(a)
user_id = authenticate_user(a)
if user_id is None:
continue
while True:
print("\nUser Menu")
print("11.View Categories")
print("12. Logout")
if user_choice == '1':
add_expense(a, user_id)
delete_expense(a, user_id)
total_expense(a, user_id)
view_expenses_by_category(a, user_id)
view_expenses_by_date(a, user_id)
view_expenses_by_month(a, user_id)
set_monthly_budget(a, user_id)
view_budget_status(a, user_id)
generate_report(a, user_id)
elif user_choice == '10':
create_category(a)
view_categories(a)
print("Logged out.")
break
else:
break
else:
conn.close()
if __name__ == '__main__':
main()
OUTPUT SCREENSHOT
REGISTRATION:
LOGIN:
ADD EXPENSES:
DEETE EXPENSE:
TOTAL EXPENSE:
CREATE CATEGORY:
VIEW CATEGORIES:
LOGOUT:
FLOW CHART
FUTURE ENHANCEMENT
➢ 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