Fast API Crash Course Code-along | Build an app with Postgres, SQL Alchemy, Async, and more

preview_player
Показать описание
This video is a Fast API Crash Course where you can code along with me and build an API for a learning management system.
Technologies used: Fast API, Postgres, SQL Alchemy, Pydantic

Thank you for watching this stream! I’d love to get to know your thoughts on it in the comments :)

——————

💸 Support my channel:

📱 Social Media

——————

Timestamps
00:00:00 - Intro
00:02:06 - Why Fast API
00:04:57 - Application Demo
00:06:57 - Install Pre-requesites
00:09:48 - Set Up Application
00:15:54 - API Endpoints
00:33:19 - Documenting the API
00:45:02 - Git & Github
00:49:58 - API Restructuring
00:58:00 - Postgres DB

DISCLOSURE: Some of the book and product links here might be affiliate links. That means that you are helping support my channel without paying any extra for the goods or services yourself. Thank you.
Рекомендации по теме
Комментарии
Автор

For someone new to FastAPI, this tutorial is invaluable. While other creators doing marathon you took your time, very easy to catch up .Thank you so much for your thorough explanation.

hasnainhasib
Автор

I'm just getting started with fast api . I'm very excited to learn from this. Would leave a comment once i end up completing it

Aniket_
Автор

I'm here after watching your tutorial on Git and Git hub beginners crash course that was really awesome 😅. Thank you so much for that.

aer
Автор

Very well explained and even complete to go on on ones own. I read and watched a lot on the topic on utube, udemy and what not... These 3 hours were very worthwhile investing. thanks so much.

dukeHH
Автор

So far, I've only watched two minutes of the course. It seems promising. However, your voice is wonderful. Just making a note of it.

anyyyel
Автор

00:27:00 in Python 3.10 I had to declare bio: Optional[str]=None or it wasn't having any of it.

laalbujhakkar
Автор

If anyone else is having trouble running the first autogenerated migration at 1:28:30 and the migration file is coming up empty in the def upgrade and def downgrade functions, open up the fast_lms database in postico and delete all the tables that we defined (users, student_courses, sections, profiles, courses, content_blocks, completed_content_blocks), also delete the empty migration file that was created and then try running the command again.

AlexMNet
Автор

Thank you for the lesson! Your teaching method is excellent, congratulations on the content.

leo
Автор

At 2:02:30, Gwen tries to manually change things in the DB, which I feel is not the best practice - and defeats the purpose of using Alembic. The problem starts from the `students.json` file (shown at 1:35:26) which has integer values for the `role`, e.g., 2, 1, etc., instead of explicit, "student", "teacher". But this alone won't fix the issue and it's all because of the Enum class. The issue is more involved and I have a solution (I found over Stackoverflow) that is better than what Gwen suggests in 1:32:00.

1. You should define sqlalchemy.Enum objects (say, Role_sa, ContentType_sa) in your user.py and course.py files in the models directory (which would be inheriting from python's enum.Enum that we defined, say, `Role` and `ContentType`). You could do it in the following way:
```
# db/models/user.py
import enum
import sqlalchemy as sa

class Role(enum.Enum):
teacher = 1
student = 2

Role_sa = sa.Enum(
Role, # defined above
name="User role",
create_constraint=True,
metadata=Base.metadata,
validate_strings=True,
)
...
# do the same for ContentType Enum and its corresponding sqlalchemy version
```

2. Use them while creating the column of the tables in the models directory. Further you should import those same sqlalchemy Enum obects (Role_sa, ContentType_sa) into the alembic version file and use them while creating columns in the `op.create_table` function. No need to add a separate line afterwards, `op.add_column` as Gwen does. Additionally, you would need to add a few lines at the top of the upgrade function and at the end of the downgrade function.

```
from db.models.user import Role_sa # defined above
from db.models.course import ContentType_sa # defined above
...

def upgrade():
Role_sa.create(op.get_bind(), checkfirst=True)
ContentType_sa.create(op.get_bind(), checkfirst=True)
# ### Commands auto generated by Alembic - please adjust! ###
op.create_table("users",
...
sa.Column("role", Role_sa, nullable=True)
)
...
op.create_table("content_blocks",
...
sa.Column("type", ContentType_sa, nullable=True
...
...


def downgrade():
...
...
Role_sa.drop(op.get_bind(), checkfirst=True)
ContentType_sa.drop(op.get_bind(), checkfirst=True)
```

Also, ensure that the seeding is done in the last version file (and add the is_active field in the JSON) so that you see this reflected in the tables.

Now if you run the migrations, everything will work like a charm!

sammathew
Автор

Congrats for a great tutorial! I understand that Swagger/OpenAPI is very helpful in such contexts, and then I feel that for real-world projects an emphasis on a proper test suite, most likely using pytest, is actually more beneficial, and should have a higher priority over the OpenAPI UI.

dinugherman
Автор

I thought this was going to be a 3hrs fast api crash course but it ended up being a 2 days solving fast api crashes course

hyszlxz
Автор

Ayyy lets goo.. One of my fav frameworks that I've been meaning to get into.

whichdude
Автор

Her voice is so lovely, that makes the tuto even more enjoyable! And she also loves cats! =) Thanks!

arochomsky
Автор

Love this tutorial, very clean and simple to understand. Thank you!

pratt
Автор

This is great! I love your work. For me its perfect! Fast API + VUE Really great resource, Thanks<3

godzilla
Автор

Thank you for this course and everything you do. I really learn from you a lot.
On 1:27:36 you imported user and course modules and it caused upgrade(), downgrade() in autogenerated file were left unpopulated. It worked well when I changed it to imort class not file as `from db.models.user import User`.

ebashirli
Автор

You're doing great job, Faraday. I'm moving to this channel now. Things are very very simplified and english is better.

abdikhaliqmohamoud
Автор

Nice course for beginners.
It would be great if you could share how the update will work on the course model?

shounakdey
Автор

Thank you for such a detailed and informative course

victorychang
Автор

would love to have a Quart crash-course.
It's the async version of the popular Flask framework...but now almost all of its most important extensions are working with Quart via the quart-flask-patch.

pietraderdetective