The Query section in the sidebar exposes a raw SQL query runner and a dedicated function calculator. This lets power users interrogate the database with any SELECT statement without leaving the browser. Both sub-tools are accessible from the same sidebar menu entry and render their output as interactive, sortable DataFrames rendered by Streamlit.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.
Custom Query Runner
The runner is wired directly to thec cursor object that database.py establishes at import time. When you click Run Query, the app executes your statement and pipes every returned row through st.dataframe().
app.py
- Open the app in your browser.
- In the left sidebar, select Query from the Tables dropdown.
- A second dropdown appears — select Custom Query.
- Type any valid SQL statement into the Enter Your Query: text input.
- Click Run Query.
- Results render immediately below as a Pandas-style DataFrame — rows are scrollable and columns are resizable.
Example Queries
All queries below are taken directly fromBackend/querry.sql. You can copy-paste any of them into the Enter Your Query: field.
JOIN Queries
1 — INNER JOIN: pumps that have at least one employee assigned Returns only the registration numbers of pumps that appear in theEmployee table’s Petrolpump_No column, i.e. pumps with at least one active employee.
NULL to find pumps that have no employee records at all.
Petrolpump table, including those that have no employee records. Unlike query 2, rows are not filtered by NULL — every pump appears regardless of staffing.
NULL in the invoice columns.
Aggregate Functions
1 — Average age of male customers Computes the meanAge across all rows in the Customer table where Gender = 'M'.
TIMESTAMPDIFF function to derive each employee’s current age in years from their stored date of birth.
Total_Price value. Useful for spotting the single highest-value transaction at a glance.
SET Operations
1 — UNION of all names (owners + employees) Combines owner names and employee names into a single deduplicated list of all named individuals associated with the pump network. TheOwners query uses the alias Names and the Employee column is referenced as EMP_Name (case-insensitive in MySQL, but used verbatim here as stored in the query file).
Petrolpump and Employee, effectively the intersection of the two sets.
Function Calculator
The Function sub-menu provides a focused UI for calling theTOTAL_AMOUNT stored function defined in MySQL. Rather than writing a raw SQL call yourself, you supply only the Tanker ID and the app handles the two-step SET @p0 / SELECT call sequence automatically.
Navigation steps:
- In the left sidebar, select Query from the Tables dropdown.
- From the second dropdown, select Function.
- Type a valid Tanker ID (e.g.
BR6872) into the Enter Tanker ID: field. - Click RUN Function.
- The result appears as a single-column DataFrame labelled Total Amount.
net_value() helper in app.py drives this flow:
app.py
TOTAL_Amount() Python function (defined in database.py) issues two consecutive SQL statements: SET @p0='<tanker_id>' followed by SELECT TOTAL_AMOUNT(@p0). The MySQL function itself multiplies FUEL_PRICE × FUEL_AMOUNT for the given tanker.
Example: Tanker JH7523 is a Diesel tanker with Fuel_Price = 87.89 and Fuel_Amount = 751.89 litres. Entering JH7523 and clicking RUN Function returns a Total Amount of ₹66,063.56.