How to build a FastAPI app with MySQL database (step by step guide)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

ความคิดเห็น • 95

  • @kal.
    @kal. 7 หลายเดือนก่อน +1

    where is the video on how to setup the mysql workbench? couldnt find it

  • @ushared-a-chregion3720
    @ushared-a-chregion3720 2 หลายเดือนก่อน +1

    really hot stuff Eric, thx for this very good explanation!

  • @상죽
    @상죽 วันที่ผ่านมา +1

    thank you very thank you.
    I’m not good at english but this video explain slowly and kindly

    • @codingwithroby
      @codingwithroby  วันที่ผ่านมา

      I am glad it was helpful!

  • @danielnahuncalcinafuentes3772
    @danielnahuncalcinafuentes3772 ปีที่แล้ว +1

    Hello, and how would be the query to get all the post of my table, without selecting one?

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      Great question! Try doing: return db.query(Post).all()

  • @ΝεοκληςΚολλιας
    @ΝεοκληςΚολλιας ปีที่แล้ว +2

    Next, could you cover the authentication and the authorization in FastAPI?

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว +3

      Not a bad idea! I will look into adding this into a future video

  • @nillsonsilva5896
    @nillsonsilva5896 6 หลายเดือนก่อน

    It works very well, however, how do i do an update for my posts ?

  • @ronjones1587
    @ronjones1587 9 หลายเดือนก่อน +1

    Thank you ! You are the best!

    • @codingwithroby
      @codingwithroby  9 หลายเดือนก่อน

      No - YOU'RE the best 🙂

  • @ushared-a-chregion3720
    @ushared-a-chregion3720 2 หลายเดือนก่อน

    I have one question to it. How can I join tables ?

  • @ericflynn5799
    @ericflynn5799 ปีที่แล้ว

    Great video, I have a small question. Whenever I delete a post and then add a new one, the post id will start from where it was last ended. For example if I create post 2 then delete it and then add another post, the new post will start from id 3. Is there anyway to reset the post id to fill in from the smallest id not being used?

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว +4

      While it might seem like a good idea to "recycle" IDs to fill gaps, there are several reasons you might not want to do this, especially if you're new to development:
      The biggest reason is data integrity.
      If you've deleted a post and reuse its ID, you might end up with links, references, or logs that point to the wrong content. This is bad for data accuracy.
      Think of how Foreign Keys work. If you have another piece of data that references that post, and then you delete the post, the old piece of data now references the new data point.
      Overall, majority of the time you do not want to reuse primary keys once they have been created, and that is why by default databases do not reuse.

    • @ericflynn5799
      @ericflynn5799 ปีที่แล้ว +1

      @@codingwithroby makes sense! Thank you for the clear explanation.

  • @alamos2404
    @alamos2404 11 หลายเดือนก่อน +1

    Excelente explicacion!😄

    • @codingwithroby
      @codingwithroby  11 หลายเดือนก่อน

      Yay! Glad you like it 🙂

  • @shreyashverma1773
    @shreyashverma1773 2 หลายเดือนก่อน

    Amazing !!

  • @azer0013
    @azer0013 4 หลายเดือนก่อน +1

    You did use Sql for chating with the data?

    • @codingwithroby
      @codingwithroby  4 หลายเดือนก่อน

      Yes, this video is using SQL.

  • @eriguzy
    @eriguzy 11 หลายเดือนก่อน

    i got this erroe
    AttributeError: module 'sqlalchemy.orm.session' has no attribute '__module__'
    how
    do i fix it please?

    • @codingwithroby
      @codingwithroby  11 หลายเดือนก่อน +1

      This is hard without me seeing any code 😢 Perhaps it is something small and you can compare your code to the video again

    • @eriguzy
      @eriguzy 11 หลายเดือนก่อน

      @@codingwithroby please sir i would like to send the pictures of the errors to you via your social media, this is my exam project and i am behind time,let me know which platform i can send the screenshot asap i really need help

    • @eriguzy
      @eriguzy 11 หลายเดือนก่อน

      hey i fixed it>>>it was a lowercase mistake of sessionlocal instaed of Sessionlocal while i was importing, thanks for the video...i will be glad if theres any video on user registration and login with authentication as well for this blog app

  • @linahmuhonja4128
    @linahmuhonja4128 5 วันที่ผ่านมา +1

    Thank you for the guide was good especially on db connection.

  • @aestriex
    @aestriex 6 หลายเดือนก่อน +1

    How do we implement HTML/CSS front-end into this application? Also, can a user login/registration system be implemented? (where users can sign up for an account and then make posts, for example)

    • @jake115577
      @jake115577 3 หลายเดือนก่อน

      th-cam.com/video/0zb2kohYZIM/w-d-xo.htmlsi=aj3W_RmtQuIOScD3

  • @demolazer
    @demolazer ปีที่แล้ว +4

    Thank you so much for this. Great explanation and structure for a beginner. I now have a clear framework to build on top of.

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      Woot woot! Glad you were able to learn and find value 🙂

  • @kgulle2
    @kgulle2 23 วันที่ผ่านมา

    Teşekkürler,
    python kodlarını videoadaki gibi renkli gösteren eklentinin adı ne acaba?

  • @mr_don_key
    @mr_don_key 3 หลายเดือนก่อน

    you didn't make a foreign key in the model ;-) (user_id is just a integer column, instead of a foreign key for id in user table)

    • @codingwithroby
      @codingwithroby  3 หลายเดือนก่อน

      Yeah, I did this because then the comments would shift to "wtf is a fk" lol. So, I remove those outliers.

  • @InspireBeforeExpire-my6fm
    @InspireBeforeExpire-my6fm 6 หลายเดือนก่อน +1

    working correct

  • @Gamingman12362
    @Gamingman12362 8 หลายเดือนก่อน +1

    damn i cant even create a virtual enviroment, that's how unprepared I am.

    • @codingwithroby
      @codingwithroby  8 หลายเดือนก่อน +1

      Ha this made me laugh - you got this!

  • @k.a.93
    @k.a.93 8 หลายเดือนก่อน +1

    cool

  • @florenciapesoa9015
    @florenciapesoa9015 ปีที่แล้ว +1

    I really liked the video. Can I use the same steps but with MariaDB?

  • @RomeuLucas1
    @RomeuLucas1 10 วันที่ผ่านมา

    Thank you! Will this work with MariaDB?

  • @youdontknowme4241
    @youdontknowme4241 3 หลายเดือนก่อน

    It is showing that could not import module “main”.
    I have done everything as per video.
    Idk whats wrong?

    • @alifmahmud2946
      @alifmahmud2946 3 หลายเดือนก่อน

      i have the same problem here.....bro..please let me know if you find any solution

    • @codingwithroby
      @codingwithroby  2 หลายเดือนก่อน

      Make sure within your terminal you are in the correct folder where the main.py file lives.

  • @manojk1494
    @manojk1494 ปีที่แล้ว +1

    2:07 I used to install dependencies one by one or by reading from a text file but this is new info thanks bro.

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว +1

      Nice! Glad you were able to learn something new 🙂 Using a requirements.txt file is probably the best solution to installing multiple dependencies at once if you already have that defined… but if you are installing multiple dependencies to a brand new project keep it all on the same line and pip install them together!

    • @manojk1494
      @manojk1494 ปีที่แล้ว +1

      Thanks for your response!

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว +1

      Of course! If you ever have any questions or need anything just post them here 🙂

  • @mehul4mak
    @mehul4mak 10 หลายเดือนก่อน

    Why you do not provide Id when creating user still it gets id number automatically?

  • @diassagatov9784
    @diassagatov9784 9 หลายเดือนก่อน +1

    amazing video, learned a lot! Tnx!

  • @williamvinct
    @williamvinct ปีที่แล้ว +1

    Hi Eric thank you so much for the clear explanation, your code is really clean

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว +1

      Thank you so much 🙂 Glad you were able to find a lot of value!

  • @vlad_the_player
    @vlad_the_player 11 หลายเดือนก่อน +1

    Nice explanation 😁 Thanks

    • @codingwithroby
      @codingwithroby  11 หลายเดือนก่อน

      I am glad you enjoyed it 🙂

  • @archanan1340
    @archanan1340 6 หลายเดือนก่อน

    Hii i have one doubt we can connect already existing database and tables also

  • @lapislazuli1949
    @lapislazuli1949 5 หลายเดือนก่อน

    where is PUT request?

  • @abdullahmusheer4238
    @abdullahmusheer4238 6 หลายเดือนก่อน

    as a newbie, i have a question, how can i host it so that external users can use it? i know we should secure it (whitelisting ip/tokens etc) but how can i load this python app to the internet for access to external users. thanks

    • @Manojkumar-fq2vu
      @Manojkumar-fq2vu 4 หลายเดือนก่อน

      use vercel, or render bro

  • @richter9911
    @richter9911 8 หลายเดือนก่อน

    for update we use
    db.put at the end?

  • @elan311X
    @elan311X ปีที่แล้ว

    Thank you so much for this, it's highly insightful _ please can you drop the syntax for update either post or user by user id as well as get all users.

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      Hey friend! If you check out some of my other FastAPI videos I go over a whole bunch of different database queries and how they work 🙂

  • @usmonbekravshanov6933
    @usmonbekravshanov6933 ปีที่แล้ว

    Could you show your code in terms of asynchronous programming? Because here you declaring api views as asynchronous functions which do not await for db calls

    • @codingwithroby
      @codingwithroby  ปีที่แล้ว

      You probably do not need to use the async here. I added it just so people could see what a final state may look like

  • @izapawlukowska4545
    @izapawlukowska4545 8 หลายเดือนก่อน

    thanks king

  • @iftikhar58
    @iftikhar58 9 หลายเดือนก่อน

    but in this code , sql connnection established again and again for each request that bad things

    • @codingwithroby
      @codingwithroby  9 หลายเดือนก่อน

      Nope that is a good thing - You do not want to keep connection on API requests!

  • @witty.coder1
    @witty.coder1 7 หลายเดือนก่อน

    Thats so great sir. I am learning form you

  • @warisshaikh9474
    @warisshaikh9474 5 หลายเดือนก่อน

    Super cool and easy steps salut to u sir love from karachi pakistan ❤

  • @svcomplex1
    @svcomplex1 11 หลายเดือนก่อน

    Thanks! Cool video. Greetings from Russia!

    • @codingwithroby
      @codingwithroby  11 หลายเดือนก่อน +1

      Glad you liked it!

  • @roozensn
    @roozensn 3 หลายเดือนก่อน

    Thanks a lot! Very helpful for beginners like me

    • @codingwithroby
      @codingwithroby  3 หลายเดือนก่อน +1

      Glad it was helpful!

  • @kavindulakmalw
    @kavindulakmalw 10 หลายเดือนก่อน

    Thank you so much for the this tutorial. keep it up.

  • @bhartendupandya3824
    @bhartendupandya3824 3 หลายเดือนก่อน

    Amazing, loved it! best content.!

    • @codingwithroby
      @codingwithroby  3 หลายเดือนก่อน

      Thank you so much 😀 Woot woot!

  • @juanriquelme1889
    @juanriquelme1889 หลายเดือนก่อน

    Thank you sir!!

  • @dianavaleriaovallevaldes1980
    @dianavaleriaovallevaldes1980 6 หลายเดือนก่อน

    many thankssss!!😿

  • @Kay-ip9fy
    @Kay-ip9fy 6 หลายเดือนก่อน

    Thanks!

  • @nmuyu
    @nmuyu 2 หลายเดือนก่อน +1

    this guy is so underrated

    • @nmuyu
      @nmuyu 2 หลายเดือนก่อน +1

      amazing editing

    • @codingwithroby
      @codingwithroby  2 หลายเดือนก่อน

      Thank you so much 😊