Databases ---- Any relational database ---ORM Library ---- SQLAlchemy Structure ---- create_user ---> UserRequest(Schema)---> Database User (Model)---> create
<------create user data------>
Database checklist
-
Database Definition ------ database.py
-
model Definition ------ models.py
-
Create database ----- main.py
-
schema definition ---- schemas.py
-
ORM functionality ---- db_user.py
-
API functionality ---- user.py
<-----Process Overview-----> -
Import required libraries : sqlalchemy, passlib, bcrypt
-
Create database definition and run it in main.py
-
Create database models (tables)
-
Create functionality to write to database
-
Create schemas: a. Data from user: UserBase b. Response to user : UserDisplay
-
Create API operation
<------CRUD Operations-----> -
Create
-
Read
-
Update
-
Delete
<----- Relationship -----> -
Retrieve elements from multiple tables in a single request.
-
Define relationship in models.
-
Add the elements we want to retrieve in schemas
<-----------Other Concepts Overview-------------> -
Error Handling --- Notify a client of an error. Raising an exception anywhere stops the code from running.
- 1XX : INFORMATIONAL
- 2XX : SUCCESS
- 3XX : REDIRECTION
- 4XX : CLIENT ERROR
- 5XX : SERVER ERROR
Provide exception handler
-
Custom Response
- Standard response is a model, list, database,, dict etc
- We can customize trhe Response object
- No data conversion (return Response(content=dat, media_type="text/html))
-
Headers
- Add headers in request function definition
- Automatic conversion between _ and -
- List of headers
- Provide custom response headers
-
Cookies
-
Form data
-
CORS