Basic project in PyCharm
FULL EXAMPLE: https://fastapi.tiangolo.com/tutorial/sql-databases/
Just create basic project in PyCharm and you can create functions for API
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Hello World"}
@app.get("/hello/{name}")
def say_hello(name: str):
return {"message": f"Hello {name}"}
PS:
SQLAlchemy uses the term "**model**" to refer to these classes and instances that interact with the database.
But Pydantic also uses the term "**model**" to refer to something different, the data validation, conversion, and documentation classes and instances.
To avoid confusion between the SQLAlchemy _models_ and the Pydantic _models_, we will have the file `models.py` with the SQLAlchemy models, and the file `schemas.py` with the Pydantic models.
These Pydantic models define more or less a "schema" (a valid data shape).
So this will help us avoiding confusion while using both.