Free courses
Data AnalysisBeginnerFree
Ask and Answer a Data Question with SQL and Python
You will ask a clear question about a small sales dataset, load it into SQLite, query it with SQL, analyse the result with Python, and create a bar chart to show the answer.
6 lessons 41 minNo account needed
Start lesson 1What you will learn
- Formulate a precise question about a dataset that can be answered with data.
- Create a small CSV dataset and load it into SQLite using Python.
- Write SQL queries to filter and aggregate data.
- Use Python to run SQL queries and prepare results for a chart.
- Create a simple SVG bar chart from query results and present the answer.
Before you start
- Use a text editor to create and save plain text files.
- Run Python scripts from a terminal or command prompt.
- Read and write simple Python code with variables, loops, and functions.
Lessons
- Lesson 1: Write a Question and Create Sample Sales DataYou choose a question you can answer with sales data, define each term, and create a small CSV file with columns for date, item, quantity, and unit price.5 min
- Lesson 2: Load the CSV into SQLite with PythonYou write a Python script that reads your CSV file and creates an SQLite database table, then checks the row count.7 min
- Lesson 3: Query the Data with SQLYou write SQL queries against your SQLite database to filter, group, and calculate total revenue per item.8 min
- Lesson 4: Run the Query from Python and Prepare ResultsYou modify your Python script to run the SQL query, fetch the results, and format them as a list of item names and revenue amounts.9 min
- Lesson 5: Create a Clear Bar Chart with SVGYou write Python code that turns the query results into a simple SVG bar chart saved as an HTML file you can open in a browser.5 min
- Lesson 6: Assemble the Analysis into a Small ReportYou combine the question, SQL query, result table, and chart into a single short document or script output that answers your question.7 min