ZMedia Purwodadi

Build a Naira Budget Tracker for Free | Step by Step Tutorial

Table of Contents
Build a Naira Budget Tracker for Free | Step by Step Guide

Build a Naira Budget Tracker for Free: Step by Step

Tracking your personal finances in Naira (₦) doesn’t require expensive software. With just a few lines of Python code, you can build your own budget tracker that records income, expenses, and even generates reports – all for free.

In this guide, you’ll learn how to create a Naira budget tracker using Python, SQLite, and Jupyter Notebook. By the end, you’ll have a working tool that you can expand and add to your data portfolio.

Let’s get started.

What You Will Build

You will build a simple but powerful personal finance tracker that:

  • Stores every transaction (income or expense) in a local database.
  • Labels each transaction with a category (e.g., “Groceries”, “Salary”).
  • Automatically adds today’s date.
  • Generates a report showing your balance and spending by category.

All code is free, open‑source, and runs on your own computer – no cloud or paid service required.

Prerequisites

Before writing code, you need two free tools:

  1. Python – the programming language.
  2. Jupyter Notebook – an interactive environment where you write and run code step by step.

How to Download & Set Up

Step 1: Download Python

Go to the official Python download page and get the latest version for your operating system (Windows, macOS, or Linux).
During installation, check the box that says “Add Python to PATH” – this makes Python work from your command line.

Step 2: Install Jupyter Notebook

Open your terminal (Command Prompt on Windows, Terminal on Mac/Linux) and run:

pip install notebook

This installs Jupyter Notebook and its dependencies.

Step 3: Launch Jupyter Notebook

In the same terminal, type:

jupyter notebook

Your browser will open a page showing your folders. Click New → Python 3 to create a new notebook.

Now you are ready to code.

Step‑by‑Step Code Walkthrough

All the code below should be typed into separate cells in your Jupyter Notebook. Press Shift+Enter to run each cell.

How To Import Required Libraries

We need three Python libraries:

  • sqlite3 – to create and work with the database.
  • pandas – to display data in a clean table.
  • datetime – to automatically capture today’s date.
import sqlite3
import pandas as pd
from datetime import datetime

Reference: Python sqlite3 documentation, pandas documentation

How To Create the Database and Table

The database file will be named finance.db. Inside it, we create a table called transactions with the following columns:

  • id – a unique number for each transaction.
  • date – when the transaction happened.
  • amount – in Naira (e.g., 5000.00).
  • category – e.g., “Food”, “Transport”.
  • description – a short note.
  • type – either 'income' or 'expense'.
# Connect to the database (creates the file if it doesn't exist)
conn = sqlite3.connect('finance.db')
cursor = conn.cursor()

# Create the transactions table
cursor.execute('''
CREATE TABLE IF NOT EXISTS transactions (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    date TEXT NOT NULL,
    amount REAL NOT NULL,
    category TEXT NOT NULL,
    description TEXT,
    type TEXT CHECK(type IN ('income', 'expense'))
)
''')
conn.commit()

Note: The CHECK constraint ensures only “income” or “expense” can be stored.

Define a Function to Add Transactions

We write a reusable function add_transaction(). It asks for the amount, category, description, and type.
The date is filled automatically.

def add_transaction(amount, category, description, trans_type):
    today = datetime.now().strftime('%Y-%m-%d')   # Example: 2025-03-20
    cursor.execute('''
        INSERT INTO transactions (date, amount, category, description, type)
        VALUES (?, ?, ?, ?, ?)
    ''', (today, amount, category, description, trans_type))
    conn.commit()
    print(f"Transaction added successfully! ₦{amount} ({trans_type})")

Add Some Sample Transactions

Let’s add a salary income and a grocery expense – both in Naira.

# Add income
add_transaction(150000, 'Salary', 'Monthly salary payment', 'income')

# Add expense
add_transaction(12500, 'Groceries', 'Weekly shopping at local market', 'expense')

After running this, the database contains two records. You can add as many as you like.

Generate a Report (View All Transactions)

To see everything, we query the database and load the result into a pandas DataFrame. This gives us a beautiful table.

# Load all transactions into a DataFrame
df = pd.read_sql_query("SELECT * FROM transactions", conn)
print("All transactions:")
df

You will see a table with columns: id, date, amount, category, description, type.

Calculate Your Balance (Income – Expenses)

To know how much money you have left, sum all income and subtract all expenses.

# Total income
total_income = df[df['type'] == 'income']['amount'].sum()
# Total expenses
total_expenses = df[df['type'] == 'expense']['amount'].sum()
# Balance
balance = total_income - total_expenses

print(f"Total Income: ₦{total_income:,.2f}")
print(f"Total Expenses: ₦{total_expenses:,.2f}")
print(f"Your Balance: ₦{balance:,.2f}")

Example output:

Total Income: ₦150,000.00
Total Expenses: ₦12,500.00
Your Balance: ₦137,500.00

Group Spending by Category

Find out where your Naira goes – which category spends the most.

expenses_by_category = df[df['type'] == 'expense'].groupby('category')['amount'].sum()
print("Expenses per category:")
expenses_by_category

This returns a small table, e.g.:

Groceries    12,500.00

(Optional) Simple Visualization with a Bar Chart

For a quick visual, use matplotlib. Install it first if you don’t have it:

pip install matplotlib

Then in your notebook:

import matplotlib.pyplot as plt

# Bar chart of expenses by category
expenses_by_category.plot(kind='bar', color='skyblue')
plt.title('Where Your Naira Goes')
plt.xlabel('Category')
plt.ylabel('Amount (₦)')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()

This creates a bar chart that helps you see spending patterns at a glance.

How to Use Your Tracker Day to Day

Every time you spend or receive money, just call add_transaction() with the correct details. For example:

# New income: freelance work
add_transaction(50000, 'Freelance', 'Web design project', 'income')

# New expense: transportation
add_transaction(3000, 'Transport', 'Bus fare for the week', 'expense')

After adding several transactions, rerun the report and balance cells to see updated numbers.

Expanding Your Naira Budget Tracker

This basic version is just the beginning. Here are ideas to make it more powerful:

  • Add a monthly budget limit – Compare your actual expenses to a target.
  • Filter by date range – Show only last month’s transactions.
  • Export to CSV – Save the DataFrame to a file for sharing.
  • Build a simple menu – Use input() to interact without coding each transaction.
  • Add a savings goal – Track progress toward a specific target (e.g., ₦200,000 for a trip).

All these expansions are beginner‑friendly and will strengthen your portfolio.

Why This Project Matters for Your Portfolio

Recruiters love seeing real‑world applications. This project shows you can:

  • Combine SQL (for storage) with Python (for logic and analysis).
  • Work with dates, numbers, and categories.
  • Produce clear reports and visuals.
  • Build something practical that solves an everyday problem.

You can host the notebook on GitHub (learn how to use Git) and share the link on your resume.

Troubleshooting Common Errors

ProblemLikely Fix
ModuleNotFoundError: No module named 'pandas'Run pip install pandas in your terminal.
sqlite3.OperationalError: no such table: transactionsYou forgot to run the table creation cell. Run it again.
TypeError: add_transaction() missing 1 required positional argumentYou must provide all four arguments: amount, category, description, type.
Jupyter notebook doesn’t openMake sure you typed jupyter notebook in the correct terminal and that Python is installed.

References & Further Reading

Conclusion

You have just built a free Naira budget tracker from scratch – no expensive apps, no monthly fees. With less than 30 lines of code, you can:

  • Record every income and expense.
  • See your current balance.
  • Find out where your money goes.

Now it’s your turn. Run the code, add your own transactions, and try one of the expansion ideas. You’ll gain confidence in Python, SQL, and data analysis – all while managing your personal finances better.

Happy coding, and may your Naira always be well tracked!

📌 Portfolio tip: This project is part of a series covering real-world scenarios like finance tracking, recommendation systems, and sales analysis. Each project combines SQL with Python for analysis and visualization. They start simple but are easy to expand – perfect for your data portfolio.

FREE 5 Real-World Data Projects You Can Do with Python + SQL(Even as a Beginner)

Post a Comment