Professional Expense Tracker in Python

Поділитися
Вставка
  • Опубліковано 21 вер 2024

КОМЕНТАРІ • 28

  • @yafethtb
    @yafethtb Рік тому +6

    The enumerate() function have a parameter called "start" to tell the function where it should start the counting. So instead using idx + 1 we can use enumerate(categories, start = 1) and the idx will start from 1.

  • @MichaelDeBusk
    @MichaelDeBusk Рік тому +2

    One easily-implemented but huge improvement would be to add a "payee" field that works the same as "category".
    I think I'd create separate tables for payee and category, too, but then it'd be more of a tutorial for sqlite than for python.

  • @rabibasukala7816
    @rabibasukala7816 Рік тому +2

    adding ui and graphs will be great .Thanks

  • @nicholasnguyen8584
    @nicholasnguyen8584 Рік тому +3

    Are we able to keep all of this data somewhere in a txt file or something?

  • @LukasFromLummerland
    @LukasFromLummerland Рік тому +3

    Very nice. Thank you! I will adapt this for a project hours tracker.

  • @akrit.ghimire
    @akrit.ghimire Рік тому +2

    That was so fun to do!

  • @BrandonHurt
    @BrandonHurt Рік тому

    I did everything right and because I use Gentoo with systemd not rc the db packages for some reason don't work unless you have rc style init system, so all of your great toots about sql won't work for me, but I utilize db's on other servers where I run email servers and such, so I still get the benefit, thanks

  • @FRANKWHITE1996
    @FRANKWHITE1996 Рік тому +1

    Thanks For Sharing ❤

  • @paulthomas1052
    @paulthomas1052 Рік тому

    Great tutorial as usual. Thanks :)

  • @xl0pate0lx
    @xl0pate0lx 9 місяців тому

    How do you open your db file in pycharm? If I click on it literally nothing happens.

  • @mjxwarrior2898
    @mjxwarrior2898 Рік тому +3

    C:\Users\memobe\PycharmProjects\demo4\venv\Scripts\python.exe C:\Users\memobe\PycharmProjects\demo4\venv\create_db.py
    Select any option below:
    1. Input a new expense
    2. View expenses summary
    1
    Enter the date of the expense (YYYY-MM-DD): 2023-01-17
    Enter the description of the expense: food
    Traceback (most recent call last):
    File "C:\Users
    ey\PycharmProjects\demo4\venv\create_db.py", line 18, in
    cur.execute("SELECT DISTINCT category FROM expenses")
    sqlite3.OperationalError: no such table: expenses
    how come it wont work?
    heres what I copied:
    import sqlite3
    conn = sqlite3.connect("expenses.db")
    cur = conn.cursor()
    while True:
    print("Select any option below:")
    print("1. Input a new expense")
    print("2. View expenses summary")
    choice = int(input())
    if choice == 1:
    date = input("Enter the date of the expense (YYYY-MM-DD): ")
    description = input("Enter the description of the expense: ")
    cur.execute("SELECT DISTINCT category FROM expenses")
    categories = cur.fetchall()
    print("Select a category by number:")
    for idx, cetegory in enumerate(categories):
    print(f"{idx + 1}. {category[0]}")
    print(f"{len(categories) + 1}. Create a new category")
    category_choice = input()
    if category_choice == len(categories) + 1:
    category = input("Enter the new category name:")
    else:
    category = categories[category_choice -1][0]
    price = input("Enter the price of the expense: ")
    cur.execute("INSERT INTO expenses (Date, description, category, price) VALUES (?, ?, ?, ?,)", (date, description, category, price))
    conn.commit()
    elif choice == 2:
    print("Select an option:")
    print("1. View all expenses")
    print("2. View monthly expenses by category")
    view_choice = int(input)
    if view_choice == 1:
    cur.execute("SELECT * FROM expenses")
    expenses = cur.fetchall()
    for expense in expenses:
    print(expense)
    pass
    elif view_choice == 2:
    month = input ("Enther the month (MM): ")
    year = input("Enter the year (YYYY): ")
    cur.execute("""SELECT category, SUM(price) FROM expenses
    WHERE strftime('%m', Data) = ? AND strftime('%Y', Date) = ?
    GROUP BY category""", (month, year))
    expenses = cur.fetchall()
    for expense in expenses:
    print(f"Category: {expense[0]}, Total: {expense[1]}")
    else:
    exit()
    else:
    exit()
    repeat = input("Would you like to do something else more interesting (y/n)?
    ")
    if repeat.lower() !="y":
    break
    conn.close()
    please help anyone I really want to learn for my career

    • @ayushsharaf1531
      @ayushsharaf1531 8 місяців тому

      bro create_db.py should be a different file and this code should be in an different file named main.py
      create a file create_db.py and paste this
      import sqlite3
      conn = sqlite3.connect("expenses.db")
      cur = conn.cursor()
      cur.execute("""CREATE TABLE IF NOT EXISTS expenses
      (id INTEGER PRIMARY KEY,
      Date DATE,
      description TEXT,
      category TEXT,
      price REAL)""")
      conn.commit()
      conn.close()

  • @xylosfroxy3526
    @xylosfroxy3526 Рік тому

    We can even use CSV file for saving expenses instead of database and can get visual presentation of our expenses category wise using matplotlib library

  • @Deadlious
    @Deadlious Рік тому +2

    nice one, just remove 'Professional' from the title. This is not a professional expense manager by no means.
    I know you need to keep it short and it is a nice example how to build a tracker of some sort with a bit of python and SQL. It's a good start for sure, but not a professional one.

  • @agape_99
    @agape_99 Рік тому

    super cool

  • @thunderskull258
    @thunderskull258 Рік тому

    This is the basic thing you can add tkinter and modern gui to it or html pyscript thing

  • @andresbonelli
    @andresbonelli Рік тому +1

    SQL integration into Pycharm seems to be a paid option, isn't any free option out there for educational purpose?

    • @distant6606
      @distant6606 Рік тому +3

      if u are a student you can get pycharm professional for free

  • @ozkanozdemir6255
    @ozkanozdemir6255 Рік тому

    Thank you bro..

  • @kevinrovik2480
    @kevinrovik2480 Рік тому

    I dont know why, but it will not allow me to do these codes, can someone help?

  • @keeskkool
    @keeskkool 7 місяців тому

    How to build GUI for this?

  • @laodefefliyarlin939
    @laodefefliyarlin939 Рік тому

    hello,
    try to talk about reinforcement learning for chabot bro

  • @hellobro1461
    @hellobro1461 Рік тому

    Please make 🙏🙏🙏🙏 a video on Python Wireless Thermal Printer using Bluetooth from Android mobile

  • @ya3ni_irqi303
    @ya3ni_irqi303 Рік тому

    Lol this guy can't code

  • @jerryogbonna3373
    @jerryogbonna3373 Рік тому

    I tried the SELECT * FROM expenses in the expense.db that was created but it gave me this error(File "/Users/jerry/Desktop/Expense Tracker/expenses.db", line 1
    SQLite format 3) what can i do, im not getting the results you are at the end.

  • @hellobro1461
    @hellobro1461 Рік тому

    Please make 🙏🙏🙏🙏 a video on Python Wireless Thermal Printer using Bluetooth from Android mobile

  • @hellobro1461
    @hellobro1461 Рік тому

    Please make 🙏🙏🙏🙏 a video on Python Wireless Thermal Printer using Bluetooth from Android mobile