Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Adarsh275/PetrolPump-Management-System/llms.txt

Use this file to discover all available pages before exploring further.

The PetrolPump table is the root entity of the entire system. Every other major record — Employees, Tankers, Sales — holds a foreign key reference back to a pump’s Registration_No. Before adding staff, fuel tankers, or sales data, you must first create the petrol pump station record that anchors them. This page walks you through all four CRUD operations available for pump records in the Streamlit UI.

Field Reference

Registration_No
string
required
Primary key. A unique alphanumeric code that identifies the station, up to 10 characters. This value cannot be changed after creation — all dependent records (Employees, Tankers, Sales) reference it by this key.Example: HPC805103
Petrolpump_Name
string
required
The trading name of the fuel station, up to 50 characters.Example: Sumaraj Petroleum
Company_Name
string
The oil-marketing company (OMC) that the station is affiliated with, up to 30 characters. Leave blank if the station is independent.Example: Hindustan Petroleum Corporation
Opening_Year
integer
The calendar year the station opened for business (stored as a 5-digit integer).Example: 2016
State
string
The Indian state in which the station is located, up to 30 characters.Example: Bihar
City
string
required
The city or town where the station is located, up to 40 characters.Example: Hisua

Add a Petrol Pump

1

Open the PetrolPump table

In the left sidebar, click the Tables dropdown and select PetrolPump.
2

Select the Add operation

In the CRUD Operations dropdown that appears below Tables, select Add.The main area will display the subheader “Enter Petrolpump Details:”.
3

Fill in the form fields

Complete the six input fields presented in the form:
FieldInput typeRequired
Registration_NoText
Petrolpump_NameText
Company_NameText
Opening_YearNumber
StateText
CityText
4

Submit the record

Click Add Petrolpump Details. A green success banner will confirm the record has been saved:
Successfully added Petrolpump details: HPC805103
The UI function that powers this form is create_for_Petrolpump() in create.py:
def create_for_Petrolpump():
    with st.container():
        Registration_No = st.text_input("Registration_No:")
        Petrolpump_Name = st.text_input("Petrolpump_Name:")
        Company_Name = st.text_input("Company_Name:")
        Opening_Year = st.number_input("Opening_Year:")
        State = st.text_input("State:")
        City = st.text_input("City:")

    if st.button("Add Petrolpump Details"):
        add_Petrolpump_data(Registration_No, Petrolpump_Name, Company_Name, Opening_Year, State, City)
        st.success("Successfully added Petrolpump details: {}".format(Registration_No))
Internally, add_Petrolpump_data() in database.py executes the following parameterised INSERT:
def add_Petrolpump_data(Registration_No, Petrolpump_Name, Company_Name, Opening_Year, State, City):
    c.execute(
        'insert into Petrolpump (Registration_No,Petrolpump_Name,Company_Name,Opening_Year,State,City) '
        'values (%s,%s,%s,%s,%s,%s)',
        (Registration_No, Petrolpump_Name, Company_Name, Opening_Year, State, City)
    )
    mydb.commit()

View Petrol Pumps

1

Open the PetrolPump table

In the sidebar Tables dropdown, select PetrolPump.
2

Select View

In the CRUD Operations dropdown, select View.
3

Expand the table

Click the “View all Petrolpumps” expander to reveal the full data set rendered as a Pandas DataFrame.
The read_for_Petrolpump() function in read.py fetches all rows and maps them to labelled columns:
def read_for_Petrolpump():
    result = view_all_Petrolpump_data()
    df = pd.DataFrame(
        result,
        columns=['Registration_No', 'Petrolpump_Name', 'Company_Name', 'Opening_Year', 'State', 'City']
    )
    with st.expander("View all Petrolpumps"):
        st.dataframe(df)
The backing query is a simple SELECT * FROM Petrolpump.

Update a Petrol Pump

1

Open the PetrolPump table

In the sidebar Tables dropdown, select PetrolPump.
2

Select Update

In the CRUD Operations dropdown, select Update.The page shows a “Current Petrolpump details” expander with the existing data, and a “Petrolpumps to Edit” selectbox pre-populated with every Registration_No in the database.
3

Choose the pump to edit

Select the target pump’s Registration_No from the dropdown. Its current field values are automatically loaded into the form inputs.
4

Edit the fields

Modify any of the five editable fields: Petrolpump_Name, Company_Name, Opening_Year, State, or City.
Registration_No is the primary key and is not editable through the update form. To change a registration number you would need to delete the record and re-create it.
5

Save changes

Click Update Petrolpump. A success message confirms the change, and the “Updated data” expander below refreshes to reflect the new values.
The SQL executed by edit_Petrolpump_data() in database.py:
UPDATE Petrolpump
SET Petrolpump_Name=%s,
    Company_Name=%s,
    Opening_Year=%s,
    State=%s,
    City=%s
WHERE Registration_No=%s

Delete a Petrol Pump

Deleting a pump is irreversible. Because Petrolpump_No is referenced as a foreign key in the Employee, Tanker, and Sales tables, attempting to delete a pump while related records still exist will raise a MySQL foreign-key constraint error and the deletion will fail. Remove or reassign all linked employees, tankers, and sales records before deleting the pump.
1

Open the PetrolPump table

In the sidebar Tables dropdown, select PetrolPump.
2

Select remove

In the CRUD Operations dropdown, select remove.
3

Choose the pump to delete

Select the Registration_No of the pump you wish to remove from the “Petrolpump to delete” selectbox. The UI shows an inline warning:
Do you want to delete :: HPC805103
4

Confirm deletion

Click Delete Petrolpump. On success, the message “Petrolpump has been deleted successfully” is displayed and the updated table is shown in the “Updated data” expander.
The SQL executed by delete_data_Petrolpump() in database.py:
DELETE FROM Petrolpump WHERE Registration_No="HPC805103"
In code:
def delete_data_Petrolpump(selected_Petrolpump):
    c.execute('DELETE FROM Petrolpump WHERE Registration_No="{}"'.format(selected_Petrolpump))
    mydb.commit()

Seed Data

The following five pump records are inserted by create_table.sql and serve as the starter dataset for development and testing:
INSERT INTO `PetrolPump`
  (`Registration_No`, `Petrolpump_Name`, `Company_Name`, `Opening_Year`, `State`, `City`)
VALUES
  ('HPC805103', 'Sumaraj Petroleum',                    'Hindustan Petroleum Corporation', 2016, 'Bihar',     'Hisua'),
  ('BP110054',  'Rajinder Service Station',              'Bharat Petroleum',                2012, 'Delhi',     'CENTRAL DELHI'),
  ('IOC560008', 'Madhu Enterprises',                    'Indian Oil Corporation',           2008, 'Karnataka', 'Banglore'),
  ('OIL380013', 'Perusahaan Minyak and Gas Bumi',       'Oil India Limited',                2006, 'Gujarat',   'Ahmedabad'),
  ('RPL673573', 'Tamarassery Reliance Retail Outlet',   'Reliance Petroleum Limited',       2013, 'Kerala',    'Thamarasserry');

Build docs developers (and LLMs) love