End-to-End Data Science Project | Beginners | Budget Tracker & Analytics | Python Pandas Plotly SQL in 2 steps

data science

You can also watch our video for this data science project :

In this blog, we will build a simple yet functional budget tracker app using Streamlit for the user interface and SQLite for data storage. The app will have user authentication features that will allow users to sign up, log in, and access their personalized budget tracking information.

For more such content and regular updates, follow us on FacebookInstagramLinkedIn

We will walk through the following steps:

  1. Setting Up the Database: Creating and connecting to an SQLite database and setting up the user authentication table.
  2. User Authentication: Building the sign-up and login functionalities.
  3. Integrating with Streamlit: Implementing the user interface using Streamlit and linking it with our backend logic.
  4. Additional Functionalities: Enhancing the app with additional features like analytics.

CREATE A FOLDER AND MAKE TWO FILES

  1. setup_db.py
  2. app.py

and copy and paste the following code.

1. Setting Up the Database

The first step is to set up the database. We’ll create a simple SQLite database with a user_table that stores user credentials.

So first open a folder and create setup_db.py file with these codes.

import sqlite3

#create a connection to the SQLite database
def create_connection():
    conn = sqlite3.connect('budget_app.db')
    return conn 

# CREATES A USER_TABLE
def create_user_table():
    conn = create_connection()
    c = conn.cursor()
    c.execute('''CREATE TABLE IF NOT EXISTS user_table (
              id INTEGER PRIMARY KEY AUTOINCREMENT,
              username TEXT NOT NULL UNIQUE,
              password TEXT NOT NULL)''')
    conn.commit()
    conn.close()

#create a new user in the database
def create_user(username,password):
    conn = create_connection()
    c = conn.cursor()
    c.execute('INSERT INTO user_table (username,password) VALUES (?,?)',(username,password))
    conn.commit()
    conn.close()

def authenticate_user(username,password):
    conn = create_connection()
    c = conn.cursor()
    c.execute('SELECT * FROM user_table WHERE username = ? AND password = ?',(username,password))
    user = c.fetchone()
    conn.close()
    return user



# create_connection()
# create_user_table()
# print(authenticate_user('xyz',123))




Python

Then create app.py file

import sqlite3
import streamlit as st 
import pandas as pd 
import plotly.express as px
from setup_db import create_connection,create_user_table,create_user,authenticate_user 

st.set_page_config(
    page_title='Budget Tracker'
)

st.title(':red[Budget Tracker]')

# initialize session state
if 'logged_in' not in st.session_state:
    st.session_state.logged_in=False 
if 'user_id' not in st.session_state:
    st.session_state.user_id=None 

signup_tab,login_tab = st.tabs(['SignUp','Login'])

with signup_tab:
    username = st.text_input('Choose your user id',key='signupusernamekey')
    password = st.text_input('Choose your Password',type='password',key='signuppasswordkey')
    signup_button = st.button('Create your account',key='signupbuttonkey')

    if signup_button:
        if username and password:
            try:
                create_user(username,password)
                st.success('Account created successfully. Go to the login page')
            except sqlite3.IntegrityError:
                st.error('Username already exists.')
        else:
            st.warning('Please provide username and password')

with login_tab:
    username = st.text_input('Enter your user id',key='loginusernamekey')
    password = st.text_input('Enter your Password',type='password',key='loginpasswordkey')
    login_button = st.button('Login',key='loginbuttonkey')

    if login_button:
        if username and password:
            user_id = authenticate_user(username,password)   #(8,himesh,456) 
            if user_id:
                st.session_state.logged_in=True
                st.session_state.user_id = user_id
                st.success(f'Welcome {username},Let us track your budget')
            else:
                st.error('Invalid Username or password')
        else:
            st.warning('Please enter username and password')

            

    

Python

Why Learn Data Science?

Data science is one of the most demanding skills in today’s job market. By learning data science, you can unlock countless opportunities in various industries. The skills you acquire can be applied to a wide range of tasks, from analyzing financial data to improving business operations.

Read more about DATA SCIENCE

Here’s how a data science course can benefit you:

High Demand: The demand for data scientists continues to grow as organizations increasingly rely on data-driven decision-making.

Diverse Career Paths: Data science skills are applicable in numerous fields, including finance, healthcare, marketing, and technology.

Lucrative Salaries: Data scientists are among the highest-paid professionals in the tech industry.

Continuous Learning: Data science is a field that constantly evolves, offering endless opportunities for growth and learning.

If you’re ready to embark on a rewarding career in data science, consider enrolling in a comprehensive course that focuses on Python.

At ConsoleFlare, we offer tailored courses that provide hands-on experience and in-depth knowledge to help you master Python and excel in your data science journey. Join us and take the first step towards becoming a data science expert with Python at your fingertips.

Register yourself with ConsoleFlare for our free workshop on data science. In this workshop, you will get to know each tool and technology of data analysis from scratch that will make you skillfully eligible for any data science profile.

Thinking, Why Console Flare?

  • Recently, ConsoleFlare has been recognized as one of the Top 10 Most Promising Data Science Training Institutes of 2023.
  • Console Flare offers the opportunity to learn Data Science in Hindi, just like how you speak daily.
  • Console Flare believes in the idea of “What to learn and what not to learn” and this can be seen in their curriculum structure. They have designed their program based on what you need to learn for data science and nothing else.
  • Want more reasons,

Register yourself  & we will help you switch your career to Data Science in just 6 months.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top