[Python] Web application from 0! Hands-on (1) -Design, DB construction-

Overview

I had the opportunity to create a web application from scratch with Python, so as a summary! This article is about designing apps, designing and building databases.

Previous article [Python] Web application from 0! Hands-on (0) ~ Environment Construction --- Qiita

I want this person to read

goal

The goal is to create a web app with CURD functionality using HTML, CSS, JavaScript, Python, and SQL.

Things necessary

1. App image

This time I would like to make a simple Todo app as a subject.

The required functions are

Let's say four. These acronyms are sometimes referred to as CRUD, and most business apps are based on these features. I created each screen image.

Todo list

The registered Todo is displayed in a list format. There is a new add button, which opens the new registration form. You can edit and delete each line from the buttons located on each line. 2020-07-31_13h42_29.png

Todo added

This is Todo's new registration form. Enter a title and click the "Add" button to add it to the list. 2020-07-31_13h43_05.png

Todo update

This is Todo's edit form. Todo will be updated by updating the title and pressing the "Update" button. 2020-07-31_13h45_18.png

Delete Todo

If you press the delete button in the list, the data in the corresponding row will be deleted. At that time, a message asking if you want to delete it will be displayed, and if you press the "Delete" button, Todo will be deleted. 2020-07-31_13h46_37.png

2. Database design

This is the only database design (laughs) The point is that by providing a column called is_deleted, it is possible to logically delete Todo. Logical deletion means that the data remains, but it appears to the user that it has been deleted by giving it a "disappeared or not disappeared" flag. It's a method. When deleting, set is_deleted = true and do not display the data for which is_deleted is true in the list.

Conversely, deleting data completely from a database with a SQL DELETE statement is called "physical deletion."

2020-07-31_14h46_24.png id: Todo ID (unique) title: The title of Todo created: The date and time when the Todo was created isDeleted: Is Todo deleted

3. Database construction

Let's actually make it from the database! pgAdmin4 is a tool that works in a browser. For Windows, type "pgadmin" in the search box on the menu bar and it should come up. 2020-07-31_14h11_51.png

From here, it will be generated in the following order. Server Group-> Server-> Database-> Schema-> Table

Creating a server group

First you need to create a server group for your database.

Select Object> Create> Server Group. 2020-07-31_14h13_03.png

The name is "Todo Servers". 2020-07-31_14h14_44.png

Creating a server

Next, create a server. Right-click on TodoServers> Create> Server. 2020-07-31_14h16_24.png

The name is "Todo Server". 2020-07-31_14h28_25.png

On the Connection tab Host name/address: localhost Password: postgres Please enter and save. 2020-07-31_14h30_10.png

Creating a database

Then create the database. Right-click on TodoServer's Databases and select Create> Database. 2020-07-31_14h39_10.png

Save it with the name "Todo Database". 2020-07-31_14h40_29.png

Creating a table

Right-click Schemas> public> Tables in TodoDatabase and select Create> Table. 2020-07-31_14h43_18.png

Name is "to do". 2020-07-31_14h44_17.png

In the Columns tab, set the columns as shown in the image and save. (You can add it from the + button on the upper right) 2020-07-31_14h45_45.png

Summary

Up to here for this time! We did a simple screen design, database design, and database construction for the app!

next time···

We will build the server side (Rest API)! [Python] Web application from 0! Hands-on (2) ~ Hello World ~ --Qiita

Recommended Posts

[Python] Web application from 0! Hands-on (1) -Design, DB construction-
[Python] Web application from 0! Hands-on (0) -Environmental construction-
[Python] Web application from 0! Hands-on (2) -Hello World-
[Python] Web application from 0! Hands-on (3) -API implementation-
[Python] Web application from 0! Hands-on (4) -Data molding-
[Python] Web application design for machine learning
Web application made with Python3.4 + Django (Part.1 Environment construction)
Access Oracle DB from Python
Web application with Python + Flask ② ③
Web application with Python + Flask ④
Web application development memo in python
Web application created with Python + Flask (using VScode) # 1-Virtual environment construction-
Python x Flask x PyTorch Easy construction of number recognition web application
WEB application development using django-Development environment construction-
[Python] A quick web application with Bottle!
Run a Python web application with Docker
Automatic posting of web design gary site with python + selenium (1) Environment construction
Easy-to-understand explanation of Python Web application (Django) even for beginners (1) [Environment construction]
Easy-to-understand explanation of Python Web application (Django) even for beginners (3) [Application creation / DB setting]
Collecting information from Twitter with Python (Environment construction)
Run a Python script from a C # GUI application
How to open a web browser from python
Python explosive environment construction starting from zero (Mac)
Import Excel file from Python (register to DB)
Steps to develop a web application in Python
[Python] Flow from web scraping to data analysis
From Python environment construction to virtual environment construction with anaconda
Get only articles from web pages in Python
Extract data from a web page with Python
Environment construction (python)
sql from python
python environment construction
MeCab from Python
Python --Environment construction
Python environment construction
python environment construction
Easy-to-understand explanation of Python web application (Django) even for beginners (6) [MTV design pattern completion]
2014 Web Application Framework Trends (PHP / Java / Ruby / Python / Perl)
(Python) Try to develop a web application using Django
Parse and visualize JSON (Web application ⑤ with Python + Flask)
Launch a Python web application with Nginx + Gunicorn with Docker
Python development environment construction 2020 [From Python installation to poetry introduction]
Web system construction (super basic) ③: DB server construction and basic operation
Procedure to exe python file from Ubunts environment construction