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.
Took me a while but this is such a great tutorial . If you're reading this try this tutorial and be ready to google things or use gpt if you don't understand it. By the end you'll gain a lot of confidence and knowledge from this tutorial. Thanks Faraday 🥰
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.
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.
@@wowomg3229 I am 2 months late, but I guess if you keep your uvicorn server running then tables are created for your database (I suspect it is sqlalchemy's doing)
Thanks! 1 year later it happened to me. I found it strange when she added this code before on the main file: user.Base.metadata.create_all(bind=engine) course.Base.metadata.create_all(bind=engine)
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.
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!
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`.
I had a similar issue... alembic revision file just said "pass" in the upgrade and downgrade functions. But my problem was the server was still running, so .Base.metadata.create_all(bind=engine) had already created the tables and alembic didn't find anything to do. But the imports shown in the video worked for me: "from db.models import ..."
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.
Thank you. Could you do a video on using uuid as primary keys with FastAPi with postgres, tried to do it but having issues. It would be great if you could migrate one model to use uuid primary key.
Hello there, God bless your efforts. I am a new sql learner having a general enquiry. How a company manages to write a documentation of its own sql application? I would be so grateful for any kind of help.
Thank you for the tutorial, it was very helpful. I was wondering is there a way to find out why the seed data is not migrated to my database. I see python code is reading the json file but it’s not inserting the seed data.
Thanks.. I have a question how a endpoint can retrieve a file like xls or pdf result of a query in any database I mean i have a query i want to transform that query with parameters in excel file in my end point.. Thanks have a nice day
You mean you want to generate a xls or pdf file from data when you hit that endpoint? There are some good libraries for that. I used Borb recently to generate pdfs in Python and that worked well
Why do the query param constraints show up on the frontend but the path param constraints do not? Is that a bug? th-cam.com/video/gQTRsZpR7Gw/w-d-xo.html
Thanks Gwen. Can you/someone mention the DB viewers that you used. You mentioned DBeaver, but there was still another one, which I did not pick up. Thanks once again.
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.
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.
Same here 😂
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
Took me a while but this is such a great tutorial . If you're reading this try this tutorial and be ready to google things or use gpt if you don't understand it. By the end you'll gain a lot of confidence and knowledge from this tutorial. Thanks Faraday 🥰
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.
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.
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.
confirming this workaround works. However, what is the root cause?
@@wowomg3229 I am 2 months late, but I guess if you keep your uvicorn server running then tables are created for your database (I suspect it is sqlalchemy's doing)
Thanks! 1 year later it happened to me.
I found it strange when she added this code before on the main file:
user.Base.metadata.create_all(bind=engine)
course.Base.metadata.create_all(bind=engine)
00:27:00 in Python 3.10 I had to declare bio: Optional[str]=None or it wasn't having any of it.
ty, i was struggling with this
Her voice is so lovely, that makes the tuto even more enjoyable! And she also loves cats! =) Thanks!
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.
Ayyy lets goo.. One of my fav frameworks that I've been meaning to get into.
It's my favorite now too
Thank you for the lesson! Your teaching method is excellent, congratulations on the content.
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!
This is great! I love your work. For me its perfect! Fast API + VUE Really great resource, Thanks
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
You're doing great job, Faraday. I'm moving to this channel now. Things are very very simplified and english is better.
She is very intelligent. Please do FastAPI with Frontend.
Love this tutorial, very clean and simple to understand. Thank you!
Thank you for such a detailed and informative course
I really liked that keyboard sound 😅
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`.
Hi its still not working for me, I tried both ways. any fix?
I had a similar issue... alembic revision file just said "pass" in the upgrade and downgrade functions. But my problem was the server was still running, so .Base.metadata.create_all(bind=engine) had already created the tables and alembic didn't find anything to do. But the imports shown in the video worked for me: "from db.models import ..."
Great tutorial, I had to turn my speakers up to the max to hear it though.
Awesome class! Thank you very much. I'm looking forward to using all these things in a project.
Followed this great tutorial with supabase as my postgres db :)
I also look forward to watch your SQLModel edition. love you
we're so lucky to have you
thank you that was helpful during my internship
Thanks for the upload. I will watch it. It will be great to have time stamps for the contents. I wonder if JWT is covered..
No JWT in this video. I'm adding some timestamps. Thanks.
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.
what a great tutorial, thanks!!
thank you very much, this was so informative.
brilliant intro to this great framework ! cheers
The writer of fast API is from Colombia, South America! :)
I made this video so long ago. Did I say some thing about him being from somewhere else?
Thank you for this course. Really appreciated and helpful, great job. I subscribed to your channel, a great explanation for a great framework!
Thank you its Nice class ,
Thank you! Nice course, very clean explanation!
Hi, i am watching this video, but how query views in postgre (not table). i get error for this. pls
Loved it ❤️ Subscribed 🙏
Really useful+I love your hair, thanks a lot ♥
Nice introduction animation video I loved so much 😊
Nice job, very detailed!
Awesome tutorial! Thank you so much
Nice course for beginners.
It would be great if you could share how the update will work on the course model?
Thank you.
Could you do a video on using uuid as primary keys with FastAPi with postgres, tried to do it but having issues. It would be great if you could migrate one model to use uuid primary key.
1:35:24
students have role set to 2 in the json file, but
1:37:23
they all have role set to NULL in the db
why?
Hello there, God bless your efforts.
I am a new sql learner having a general enquiry.
How a company manages to write a documentation of its own sql application?
I would be so grateful for any kind of help.
Very informative 👍
Thanks for the course :)
@Faraday Academy. I am trying to inserting the bulk data via alembic but it is not working. Can you help me here ?
Love this tutorial 🥰🥰..
Thanks you're so cool.
Thank you for the tutorial, it was very helpful. I was wondering is there a way to find out why the seed data is not migrated to my database. I see python code is reading the json file but it’s not inserting the seed data.
Great! Thanks you.👏
Hi good work keep it up.
Awesome video! I cant find JavaScript for a beginner on your TH-cam channel...
Discord link is invalid, I can't sign up for your newsletter even though I have a valid email it shows invalid.
Bookmarked.
Well done!!
Thanks.. I have a question how a endpoint can retrieve a file like xls or pdf result of a query in any database I mean i have a query i want to transform that query with parameters in excel file in my end point.. Thanks have a nice day
You mean you want to generate a xls or pdf file from data when you hit that endpoint? There are some good libraries for that. I used Borb recently to generate pdfs in Python and that worked well
@@FaradayAcademy yes .. please can make some kind of video how to implement this library inside endpoint
Good
nice! can you build something in the front-end as the part 2 of this video?
Why do the query param constraints show up on the frontend but the path param constraints do not? Is that a bug?
th-cam.com/video/gQTRsZpR7Gw/w-d-xo.html
Hi Faraday , Thanks for you videos , i have a question, i I'm not familiar with pgsql , do u have some document about mysql ?
No, I really don’t use MySQL anymore and I’m not sure if I will ever make a tutorial on that.
Thanks Gwen. Can you/someone mention the DB viewers that you used. You mentioned DBeaver, but there was still another one, which I did not pick up. Thanks once again.
It is shown at 1:03:00
Can anyone write test cases in fastapi for login successful and get homepage as a result??
Please make a tutorial of deploying this to aws/digital ocean
Hey can u do a tutorial on FastAPI and Vue.js?
Uh
I can't wait any longer.
Still 16h 🙄
😁 I hope it’s worth the wait for you.
The discord invite is expired :(
What is the difference between this course and that 4 hour fast api course?
The other one on my channel is a live stream. This video is an edited tutorial.
can you update the file in github?
mam Can use please make a video on how to calculate idle time in vuejs
cuando lo anexas a Vue js Saludos!!!
Ben bu Vim'i bir türlü öğrenemedim ya :(
I love your content but I have one question.
python programming language or scripting language
Python is for scripting too. Are you asking which language to learn? Depends on what you are trying to do or looking for in a programming language.
Now you are my crash=) not your crash course
this isnt an app, its an api. wheres the front end?
Oh gosh! You are so cute ❤
increase the volume lady!
Thank u so much