Python API Development - Comprehensive Course for Beginners

freeCodeCamp.org · 3.2M views · 2021 · 19:00:27

Open on YouTube

Web developmentPython, Ruby & scripting languagesSoftware architecture & designcourse

Why Stack Overflow recommends it

Stack Overflow users cite it as the tutorial they were following when they hit errors, and they reference timestamps from it when asking about FastAPI, SQLAlchemy, Postgres and JWT problems.

Recommended by 2 people across 2 different months, 2022 to 2024.

What it is

A 19-hour freeCodeCamp course by Sanjeev Thiyagarajan that builds a full REST API in Python with FastAPI. It covers routes, Pydantic validation, PostgreSQL and SQLAlchemy, JWT authentication, pytest testing, Docker, Alembic migrations and a GitHub Actions CI/CD pipeline.

What people said

Recommends George · 2023-07 · Stack Overflow · on “API development, FastAPI / SQLAlchemy , relationship() question”

I am working on completing an API development course ( here [this video] ). I am currently at 8:33:37 Sqlalchemy Relationships and have run into an issue. In this course we have two tables; "posts" and "users". Here is the code from my models.py file: from .database import Base from sqlalchemy import Column, Integer, String, Boolean, TIMESTAMP, text, ForeignKey from sqlalchemy.orm import relationship class Post(Base): __tablename__ = "posts" id = Column(Integer, primary_key=True, nullable=False) owner_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False,) title = Column(String, nullable=False) content = Column(String, nullable=False) published = Column(Boolean, server_d

Recommends ajay · 2023-08 · Stack Overflow · on “Getting an error while trying to run PostgreSQL in container on GitHub Actions runner”

The example in this question comes from a fast API course on youtube [this video] I was following it and ran into same issue. The issue is that in our main file we have below statement which expects a DB name 'fastapi' from database.py file models.Base.metadata.create_all(bind=engine) In your yml file you are creating database with name fastapi_test, so it doesnt find fastapi and hence errors out env: POSTGRES_PASSWORD: ${{secrets.DATABASE_PASSWORD}} POSTGRES_DB: fastapi_test POSTGRES_USER: ${{secrets.DATABASE_USERNAME}} Solution1: Tested and Works fine for me Keep the database name POSTGRES_DB: fastapi in yml file as we only need one database for the test and don't need an additional fastapi_tes

Cites Ryperson · 2022-11 · Stack Overflow · on “Why am i getting an error when i import a moduel”

Im using fast api, and postgresql, they are in the same directory, the youtube video link is [this video] and the time he does this is at 5:02:30

Cites cookie1986 · 2022-12 · Stack Overflow · on “Updating Azure Database for PostgreSQL flexible server using Alembic”

I'm looking to amend some tables I have in a PostgreSQL instance on Azure, but I cannot work out how to perform the upgrades with Alembic. I have been following the tutorial here [this video] , which includes a Heroku deployment around the 12:01:00 mark. In that case, once the changes have been defined, we can run heroku run "alembic upgrade head" to perform the upgrade. However, I cannot find the equivelant process for Azure. My postgres instance is housed in a VNet and connected to a web app. Until now, I've made code changes to a server which is running in an attached web app. I push to GitHub which then deploys the changes in Azure. Obviously, if the table already exists in postgres, changes

Cites AntonioMoreno · 2023-01 · Stack Overflow · on “sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "postgres" to address: nodename nor servname provided”

I am following a [this video] to create an API using FastAPI. I am new to both Docker and FastAPI. I have managed to create a Docker container for the API and another one for the Postgres database using this Dockerfile and docker-compose: Dockerfile: FROM python:3.9.7 WORKDIR /usr/src/app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY . . docker-compose: version: '3' services: api: build: . depends_on: - postgres ports: - 80:8000 volumes: - ./:/usr/src/app.ro env_file: - ./.env command: bash -c "uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload" postgres: image: postgres ports: - 5432:5432 env_file: - ./.env volumes: - postgres-db:/var/lib/posgresql/data v

Cites JanLodewijk · 2024-04 · Stack Overflow · on “JWT token error: input should be a valid string”

I’m trying to follow Sanjeev’s tutorial on python API developement ( [this video] 1). Until 7,5 hours I didn’t get any trouble, but now I’m trying to create a new post in postman, using a JWT token as authentication. When I try to do this, I get this error: “pydantic_core._pydantic_core.ValidationError: 1 validation error for TokenData id Input should be a valid string [type=string_type, input_value=14, input_type=int]” I'm pretty sure I've followed along with the tutorial and that the token is a string, so I don't know where it's going wrong. I’ll try to provide all the relevant code, but if you’re missing something, please let me know. From schemas.py: class TokenData(BaseModel): id: Optional[s