This program helps users manage expenses by entering and viewing spending summaries. It uses an SQLite database for storing and seeing expense data.
This Python program helps individuals keep track of their expenses. It provides a user-friendly command-line interface for users to enter new expenses and view summaries of their spending. The program stores all the expense data in an SQLite database.
This program begins by importing the modules, 'sqlite3' and 'datetime'. It establishes a connection to an SQLite database named 'expenses.db' using the 'sqlite3.connect()' function.
The code executes an SQL command to create a table named "expenses" If it doesn't exist i.e. when we run the 'main.py' code given above the table is created. The "expenses" table has columns for 'id', 'Date', 'description', 'category', and 'price'.
To enter the expense we need to run the 'main1.py' code. If the user selects the option to enter a new expense (choice 1), they are prompted to input the data of the expense (in the format YYYY-MM-DD) and a description.
The program will check the existing expense categories from the database and display the user with a choice to select an existing category or create a new one. The user inputs the price of the expense. The program inserts the entered expense details into the 'expenses' table in the database.
If the user selects the option to view expense summaries (choice 2), they can choose between viewing all expenses or viewing monthly expenses grouped by category. For all expenses, the program gives all rows from the "expenses" table and displays them. For monthly expenses, the user inputs the desired month and year, and the program displays expense totals for each category.
After each operation, the user is asked if they want to perform another action. If the user responds with "y", the loop continues; otherwise, the program exits.
At the end of the program, the database connection is properly closed using the 'conn. close()' function.
Here are some requirements for this code:
1. Language: Python3
2. Libraries: sqlite3
Submitted by Anjan Kumar M L (anjan15)
Download packets of source code on Coders Packet
Comments