Tracker
Tracker
connector
import pandas as pd
import matplotlib.pyplot as plt
def monthly_expenses_table():
# Query to get total expenses grouped by month
query = """
SELECT
DATE_FORMAT(date, '%Y-%m') AS month,
SUM(amount) AS total_expense
FROM expenses
GROUP BY month
ORDER BY month;
"""
cursor.execute(query)
res = cursor.fetchall()
if res:
df = pd.DataFrame(res, columns=['Month', 'Total Expense'])
else:
print("\nNo expenses recorded yet.")
if choice == "1":
date = input("Enter date (YYYY-MM-DD): ")
category = input("Enter category (e.g., Food, Transport,
Entertainment): ")
amount = float(input("Enter amount: "))
description = input("Enter description: ")
add_expense(date, category, amount, description)
else:
print("Invalid choice. Please try again.")