Python Personal Expenses Web App with Streamlit & SQLite

Поділитися
Вставка
  • Опубліковано 30 чер 2023
  • I had previously created a Glide, no code Personal Expense App and found it extremely useful. The Glide Apps are Web Apps and they originally wrote data to a Google Sheet in your account. See Glide Apps : www.glideapps.com/
    It is a great app but I found it a bit slow to respond as data from the app went to the Google Sheet via Glide & then back through Glide to display update on the app on your mobile. It was a bit laggy. Since then they now have a data collector inside of Glide so no need to go to Google Sheets.
    As I’ve been developing my skills as a programmer I wanted to do the same app in Python to see if it was more responsive than my original Glide App.
    I searched the interwongle and UA-cam for ideas ad I found Sven’s Streamlit app a good starting point for what I wanted. See You Tube ”python streamlit expense app” search: ua-cam.com/users/results?searc...
    In Sven’s app for the backend he used a noSQL database with Deta platform which seems to be in beta phase. When I tried to replicate his app witj the code he gave I found that the Deta interface has changed since his video. So looked to use a different way to store the data.
    I’d played with using SQLite before but wanted to use it on a project, so decided that I’d use it on this project to store the data. The appeal is that your database is a single local file, so you can store it where you have your python script.
    My one issue with SQLite DB was viewing the DB and I found that Izaias from Ahl the Automator used SQLite Studio to do this . SQLite Studio: sqlitestudio.pl/
    So I now had all the elments that I needed to write and develop the script.
    I personally struggle with coding a project I’ve done before and found it difficult, after the initial research on what type of tools I wanted to use to build the app to get sufficiently motivated to build something I’d built before.
    At this time I saw that Google Bard was available for people to try outside of the US so I decided to compare it against Bing Chat to see how they both behaved. I wrote a simple prompt:
    Can you write python streamlit app that you can select from a list a 'category' (category=[rent, food,rates]) and have an input field for sum in $ for amount and a date selector, default today, with a note field of say 150 chars and a submit button that will then put into a SQLite3 table
    Can you add another field, 'payee' which can be a list (to=[paknsave, wharehouse, wharehouse mobile, WCC, countdown]) but you can add extra values to this list , and make the list a table in the SQLite DB so it reads the table but if new value added to a specific transaction it will also be added to the to table
    And was impressed with the output from both Bard & Bing Chat, and was keen to test out the barebones scripts that they wrote for the app. So tested them and added features in snippets to the initial prompt to get all the features that I needed to build the app.
    I found their scripts great for connecting to the DB and doing CRUD (Create.Read.Update. Delete) operations required for the app really easy to use and incorporate into the script.
    The script could be refined and rationalized as there are a lot of repetitive functions, but it works and I’m happy with that.
    The one issue I had was getting data from the DB and making it accessible to the User. So I have an Export to CSV button but that requires the file to be accessible to the end user. To make that happen, when the App is deployed to a remote server required the file to be emailed to the user, and I did that via 2 external scripts, one for Expenses & one for In\come.
    The basic elements of the app all work. I just need to decide on what UI want displayed on the summary tab, which I will look at after testing the app for a while.
    I am considering a further video where I will deploy the app on the Streamlit cloud to see if that works. Currently the app will run locally & I have it also running on my personal VPS (Virtual Private Server).
    Overall I’m pleased wih the process & the app after a slow start & have been impressed with the results from Bard & Bing Chat for creating an initial app from a simple prompt.
    Script Link: drive.google.com/drive/folder...
    I hope this is of help to you, if so, can you please give a thumbs up for the video. Muchas Gracias Please visit my blog for similar topics: cr8ive.tk
    Kind regards, Max Drake

КОМЕНТАРІ • 3

  • @sv4647
    @sv4647 6 місяців тому +1

    I have a question how did your streamlit app directly open in dark mode?
    Is there a code to make dark mode as default?

    • @MaxDrake
      @MaxDrake  6 місяців тому +1

      Hi @sv4647,
      I did this a while ago- not sure if it automatically saw what theme I was using on my PC (Win10) or if I specifically coded for it.
      There is this UA-cam video for Dark Theme ua-cam.com/video/iUgNIFrVejc/v-deo.html
      You can also download my code from Here:
      drive.google.com/drive/folders/1exzHognJY59XdaSSHZzXuPARFdLyf7s0?usp=sharing
      I had a quick look at the AppC2.py file for streamlit app and under:
      ## Config streamlit page there does not seem to be anything specific for theme, so I think its getting it from my Browser (firefox ) , but Just checked and dark in Edge too.
      I think its taking theme setting from Win 10 system theme.
      Hope that helps,
      Happy New Year to you,
      kind regards,

    • @sv4647
      @sv4647 6 місяців тому +2

      @@MaxDrake Thank you!