Grocery Store Application - 6. List orders | Python project tutorial

codebasics · Beginner ·🌐 Frontend Engineering ·5y ago

Key Takeaways

The video demonstrates creating a backend API for a grocery store application using Python, connecting to a database, and displaying orders on the home page. It also covers deploying the application to AWS, using a config file for database credentials, and adding unit and integration tests.

Full Transcript

in this session we will work on displaying the orders in this particular screen this will be a home page or a dashboard for our application where a grocery store runner can see all the orders which are received so far he can also see the total cost or the total of all the orders so he gets an idea on uh the total business that he is doing so first we will write as usual the python backend api for this so i will go to orders dao and i have created this function called get all orders and i'll just call it from here first okay so usual our usual thing is you create a connection cursor then you say cursor.executequery and what is the query well your query is actually very simple for the orders it will be select star from orders okay we have two tables for the orders order and order details right now we are going to display only the orders not the order details you see in the grid here see these are orders like order customer name total cost we are not showing the details of that order in that grid so this query is good enough once it is executed you will do for record in cursor do something okay what do you want to do you want to return all these orders in an array so i will just say response and response dot append something so i will return it as a dictionary and then return this response can be written from here okay so what do i get here as a tuple when we have an execute this query you get all these columns order id customer name total and date time so that's what i will type in here order id customer name [Music] total date time order id is order id customer name is that total this total and the time is take time all right so you see you are getting all these orders back now we are going to write an api in our server.pi and that api is very simple actually you just create an endpoint so this is what we'll use to call make a call from ui the method is of course get and i am using the same uh order dow dot get or all orders okay so let's run this so now i'm running the server my server is all set and ready now comes the front end in the ui i have this file called dashboard.js okay so if you say dashboard.js that's what dot js i'm referring it from index html see index html in any way programming is the home page so this is my home page uh this this particular thing is my home page in the home page i'm referring to dashboard.js and that's what dot js i'm making a call to order list api which is as you see it is get all orders get all orders and get all orders these two things should be matching and then once i return the response i'm running a for loop as usual and putting all the orders into a table so this is my table where i'm inserting a table row so table row is indicated by tr element okay and this td is the individual cells in that row so whatever i'm getting from the back and i'm just displaying it i'm i'm uh restricting the decimal places to two decimal i don't want to display too big float number that's why so let's test this so i will right click inspect i'll go to dashboard and i'll put a breakpoint here you see i have a breakpoint here and i refresh so when i refresh i get this response back and this response has all this order see you see that so now i'm just going through these orders one by one and these orders are displayed by the way this each if you want to go inside you have to put a breakpoint here you know because it's kind of like async hoodie our application is done now all right we have nice application here it's it's a simple application it needs a lot of improvements but at least you build end-to-end application using python and some web technologies now as an exercise if you go to my github page the link is in video description below you need to uh you know show the order details because here i have the order okay 530 rupees but what did i buy toothpaste rice what is the details of that order so if you put a new column here and add a button see in manage product i had this button okay so similar to this button i can add a view order button when you click on that you show all the individual items in a new screen for that particular order and after you do that yeah so that's an exercise like i have given other exercises as well so there are total five exercises that you need to work on overall as this project continues now working on this exercise will um consolidate your knowledge and just by watching the video you don't learn coding for learning coding you have to do the exercise on your own i don't have the exercise solution i want some of you to work on this solution and then give me a pull request so you can fork this repo in a fork click on fork and then add a directory called solution here which should have solution for all these five exercises and give me a pull request i will pick the best answer and i will merge it and i will give that person a credit that you're also contributing uh and you're helping people once this kind of project is done see this this project is still running in dev if you want to do some freelancing work and go to nearby grocery shop and give it to them you have to deploy this on a cloud so for cloud deployment if you do let's say or basics uh deploy a model to production i have this video where i deployed plus flash server to aws you can use same exit video and deploy the whole application to aws so i hope you will do that aws has a free tier so you can just use that three tier and deploy the code okay so you do that there are also some after thoughts which is managing the database connection etc in a config file so right now in my database if you look at it you know in the code itself i am maintaining username password all of that usually in the production application you will have some kind of config where you have development alpha and production credentials for your database connection and so on you maintain that there and then you read it so i hope you can add that as well a good production code um if you're working in any corporate company will also have a automated test you know unit test and integration test so i did not cover it but i have pi test tutorial so you can watch those and maybe add some unit test people use get as a source code management tool so if you are doing this project along with your friend uh you know you can work on product model your friend can work on order module and you both can collaborate and do this project together so you do this project and the exercises together and use git for source code management you know so that way you get a good understanding of git as well then you can also do each other's code review if you are working for a company the code review process is very normal it is it is something that happens so you are working in a group now you can review your friends code your friend can review your code and that way you you build some skills which will be very helpful uh you know to get a job and then deployment in cloud is something we already talked about now i have a discord server here um so if you join my discord server there is a partner in group finder so using this group you can find people you can make a group and you can do projects together okay so use the discord server there are many other channels which could be useful as well for git i have git tutorials so you can watch this tutorials and use git uh if you do like pie test tutorial there are like quietest tutorials i have which will help you right you need a unit test and so on so whatever you need in order to make yourself ready for industry and job we have all that information all you need is a little will okay so i hope you enjoyed this series so far we are concluding this series this is the last video and uh if you like it give it a thumbs up share it with your friends um you can also if you are interested in web development maybe play with the ui change the colors change the background image just play with it and make it look like your own application now this application was grocery store management you can make similar application for medical store or any other business pretty much you know we covered three tier application development ui back-end database and connecting these three pieces together and this gave you a very good exposure of all everything that you need to build uh the the full application okay so thank you very much for watching and i hope you will work on exercise leave me a comment if you have any questions

Original Description

📺 In this video we will write code to list orders on home page for our grocery store application (Python project). Code & Exercise: https://github.com/codebasics/python_projects_grocery_webapp Link for english playlist: https://www.youtube.com/playlist?list=PLeo1K3hjS3uu1hh_qzBt6e379cofVD9Sb Link for hindi playlist: https://www.youtube.com/playlist?list=PLPbgcxheSpE0bAjT2NzU2crJVTwh9fhO4 Prerequisites links: python english tutorial: https://www.youtube.com/playlist?list=PLeo1K3hjS3uv5U-Lmlnucd7gqF-3ehIh0 python hindi tutorial: https://www.youtube.com/playlist?list=PLPbgcxheSpE1DJKfdko58_AIZRIT0TjpO https://www.khanacademy.org/computing/computer-programming/html-css https://www.khanacademy.org/computing/computer-programming/sql Do you want to learn technology from me? Check https://codebasics.io/ for my affordable video courses. #️⃣ Social Medias #️⃣ 🔗 Discord: https://discord.gg/r42Kbuk 📸 Instagram: https://www.instagram.com/codebasicshub/ 🌎 Website: http://codebasics.io/ 🔊 Facebook: https://www.facebook.com/codebasicshub 📱 Twitter: https://twitter.com/codebasicshub 📝 Linkedin: https://www.linkedin.com/company/codebasics/ ❗❗ DISCLAIMER: All opinions expressed in this video are of my own and not that of my employers'.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from codebasics · codebasics · 0 of 60

← Previous Next →
1 Python Tutorial - 1. Install python on windows
Python Tutorial - 1. Install python on windows
codebasics
2 Python Tutorial - 2. Variables
Python Tutorial - 2. Variables
codebasics
3 Python Tutorial - 3. Numbers
Python Tutorial - 3. Numbers
codebasics
4 Python Tutorial - 4. Strings
Python Tutorial - 4. Strings
codebasics
5 Python Tutorial - 5. Lists
Python Tutorial - 5. Lists
codebasics
6 Python Tutorial - 6. Install PyCharm on Windows
Python Tutorial - 6. Install PyCharm on Windows
codebasics
7 PyCharm Tutorial - 7. Debug python code using PyCharm
PyCharm Tutorial - 7. Debug python code using PyCharm
codebasics
8 Python Tutorial -  8. If Statement
Python Tutorial - 8. If Statement
codebasics
9 Python Tutorial - 9. For loop
Python Tutorial - 9. For loop
codebasics
10 Python Tutorial -  10. Functions
Python Tutorial - 10. Functions
codebasics
11 Python Tutorial - 11. Dictionaries and Tuples
Python Tutorial - 11. Dictionaries and Tuples
codebasics
12 Python Tutorial - 12. Modules
Python Tutorial - 12. Modules
codebasics
13 Python Tutorial - 13. Reading/Writing Files
Python Tutorial - 13. Reading/Writing Files
codebasics
14 How to install Julia on Windows
How to install Julia on Windows
codebasics
15 Python Tutorial - 14. Working With JSON
Python Tutorial - 14. Working With JSON
codebasics
16 Julia Tutorial - 1. Variables
Julia Tutorial - 1. Variables
codebasics
17 Julia Tutorial - 2. Numbers
Julia Tutorial - 2. Numbers
codebasics
18 Python Tutorial - 15. if __name__ == "__main__"
Python Tutorial - 15. if __name__ == "__main__"
codebasics
19 Julia Tutorial - Why Should I Learn Julia Programming Language
Julia Tutorial - Why Should I Learn Julia Programming Language
codebasics
20 Python Tutorial  - 16. Exception Handling
Python Tutorial - 16. Exception Handling
codebasics
21 Julia Tutorial - 3. Complex and Rational Numbers
Julia Tutorial - 3. Complex and Rational Numbers
codebasics
22 Julia Tutorial - 4. Strings
Julia Tutorial - 4. Strings
codebasics
23 Python Tutorial -  17. Class and Objects
Python Tutorial - 17. Class and Objects
codebasics
24 Julia Tutorial - 5. Functions
Julia Tutorial - 5. Functions
codebasics
25 Julia Tutorial - 6. If Statement and Ternary Operator
Julia Tutorial - 6. If Statement and Ternary Operator
codebasics
26 Julia Tutorial - 7. For While Loop
Julia Tutorial - 7. For While Loop
codebasics
27 Python Tutorial  - 18. Inheritance
Python Tutorial - 18. Inheritance
codebasics
28 Julia Tutorial - 8. begin and (;) Compound Expressions
Julia Tutorial - 8. begin and (;) Compound Expressions
codebasics
29 Python Tutorial - 12.1 - Install Python Module (using pip)
Python Tutorial - 12.1 - Install Python Module (using pip)
codebasics
30 Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
codebasics
31 Julia Tutorial - 10. Exception Handling
Julia Tutorial - 10. Exception Handling
codebasics
32 Python Tutorial  - 19. Multiple Inheritance
Python Tutorial - 19. Multiple Inheritance
codebasics
33 Python Tutorial - 20. Raise Exception And Finally
Python Tutorial - 20. Raise Exception And Finally
codebasics
34 Python Tutorial - 21. Iterators
Python Tutorial - 21. Iterators
codebasics
35 Python Tutorial - 22. Generators
Python Tutorial - 22. Generators
codebasics
36 Python Tutorial - 23. List Set Dict Comprehensions
Python Tutorial - 23. List Set Dict Comprehensions
codebasics
37 Python Tutorial - 24. Sets and Frozen Sets
Python Tutorial - 24. Sets and Frozen Sets
codebasics
38 Python Tutorial - 25. Command line argument processing using argparse
Python Tutorial - 25. Command line argument processing using argparse
codebasics
39 Debugging Tips - What is bug and debugging?
Debugging Tips - What is bug and debugging?
codebasics
40 Debugging Tips - Conditional Breakpoint
Debugging Tips - Conditional Breakpoint
codebasics
41 Debugging Tips - Watches and Call Stack
Debugging Tips - Watches and Call Stack
codebasics
42 Python Tutorial - 26. Multithreading - Introduction
Python Tutorial - 26. Multithreading - Introduction
codebasics
43 Git Tutorial 3:  How To Install Git
Git Tutorial 3: How To Install Git
codebasics
44 Git Tutorial 1: What is git / What is version control system?
Git Tutorial 1: What is git / What is version control system?
codebasics
45 Git Tutorial 2 : What is Github? | github tutorial
Git Tutorial 2 : What is Github? | github tutorial
codebasics
46 Git Tutorial 4: Basic Commands: add, commit, push
Git Tutorial 4: Basic Commands: add, commit, push
codebasics
47 Git Tutorial 5: Undoing/Reverting/Resetting code changes
Git Tutorial 5: Undoing/Reverting/Resetting code changes
codebasics
48 Git Tutorial 6: Branches (Create, Merge, Delete a branch)
Git Tutorial 6: Branches (Create, Merge, Delete a branch)
codebasics
49 Git Github Tutorial 10: What is Pull Request?
Git Github Tutorial 10: What is Pull Request?
codebasics
50 Git Tutorial 7: What is HEAD?
Git Tutorial 7: What is HEAD?
codebasics
51 Git Tutorial 9: Diff and Merge using meld
Git Tutorial 9: Diff and Merge using meld
codebasics
52 Difference between Multiprocessing and Multithreading
Difference between Multiprocessing and Multithreading
codebasics
53 Python Tutorial - 27. Multiprocessing Introduction
Python Tutorial - 27. Multiprocessing Introduction
codebasics
54 Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
codebasics
55 Git Tutorial 8 - .gitignore file
Git Tutorial 8 - .gitignore file
codebasics
56 Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
codebasics
57 Python Tutorial - 30. Multiprocessing Lock
Python Tutorial - 30. Multiprocessing Lock
codebasics
58 Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
codebasics
59 What is code?
What is code?
codebasics
60 Python unit testing - pytest introduction
Python unit testing - pytest introduction
codebasics

This video teaches how to create a backend API for a grocery store application, connect to a database, and display orders on the home page. It also covers deploying the application to AWS, using a config file for database credentials, and adding unit and integration tests. By following this tutorial, viewers can learn how to build a fully functional web application using Python and MySQL.

Key Takeaways
  1. Create a connection to a database and execute a query to retrieve orders
  2. Return the orders as a dictionary in an array
  3. Create an API endpoint in the server to handle GET requests for orders
  4. Make a call to the API using JavaScript and display the orders in a table
  5. Fork the repo and add a directory called solution with exercise solutions
  6. Deploy the application to AWS using the free tier
  7. Use a config file to manage database connection credentials
  8. Add unit tests and integration tests
💡 Using a config file to manage database connection credentials is a good practice for securing sensitive information.

Related AI Lessons

Had my Frontend Developer interview with Capgemini (Application Developer) today, and I wanted to…
Prepare for a frontend developer interview with Capgemini by reviewing JavaScript fundamentals and practicing common interview questions
Medium · JavaScript
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with 10 essential tools for modern web app development
Medium · Programming
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with top 10 developer tools in 2026
Medium · JavaScript
The US Frontend Engineer Market in 2026: A Data-Driven Reality Check (and the Bias That Stops Us Seeing It)
US frontend engineer hiring demand peaked in 2022 and remains flat-depressed in 2026, contrary to common assumptions
Dev.to AI
Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →