FastAPI & SQLModel - Database Interaction in FastAPI apps with SQLModel

Поделиться
HTML-код
  • Опубликовано: 14 окт 2024

Комментарии • 49

  • @dixon1e
    @dixon1e 5 месяцев назад +3

    This is incredibly well produced and deeply informative. Thank you.

    • @bugbytes3923
      @bugbytes3923  5 месяцев назад

      Thanks a lot, delighted to hear that! Cheers!

  • @LaichuTV
    @LaichuTV 2 месяца назад +1

    Bro thank you for creating these videos, deeply respect!

    • @bugbytes3923
      @bugbytes3923  2 месяца назад +1

      Thanks a lot for the comments bro, cheers!

  • @opticonor
    @opticonor 6 месяцев назад +2

    Lots of value in this video, thanks!!

  • @thierryyolepiot9951
    @thierryyolepiot9951 4 месяца назад +6

    Can you show hoz to set up FastAPI with MySQL and PostGreSQL (especially with the async features)?

  • @djtoon8412
    @djtoon8412 4 месяца назад +1

    also setting up with postgres docker and traefik .Also an additional content can be sending emails and show how to create email templates

  • @abdullahbutt324
    @abdullahbutt324 Месяц назад +2

    In case someone got the error saying "No details". Its because u need to restart the server again. So its better that u add the keyword --reload after the uvicorn command. Then try again it will run smoothly

  • @tascsolutions6483
    @tascsolutions6483 5 месяцев назад +1

    Great content! Can you please explain why some tutorials use pydantic models(schemas) AND sql models (models)? I find this confusing and causing issues.

    • @matis9783
      @matis9783 5 месяцев назад

      Maybe single responsibility principle

    • @TOn-fx2gr
      @TOn-fx2gr 4 месяца назад

      That's how it worked in the paste but then the developer of fastapi created sqlmodel which use pydantic and sqlalchemy under the hood to make our life much easier ,i think most people in youtube are not aware that sqlmodel exist

  • @tejas8211
    @tejas8211 Месяц назад

    Why did you not chose SQL Alchemy for this demonstration ?

  • @MubasharDev-d7t
    @MubasharDev-d7t 7 дней назад

    I am new to fastapi and all backend stuff. Maybe I ask silly question but kindly response me ASAP as I am learning it on my full power 😅
    How can I deploy it on vercel? As I've been deploying it on vercel previously without any database. The file db.sqlite how can I manage that. For example me app is in production and wanted to do some changes in APIs or add new tables. And give it a push to github for auto deploy on vercel. Won't it wipe the previous database? How can I protect the latest database. I am much confused on this.

  • @Steve51791
    @Steve51791 3 месяца назад +1

    Why should one create subclasses and inherit from a base class? Is there a reason you shouldn't just, for example, put the primary key field in the parent class?

  • @juvewan
    @juvewan 6 месяцев назад +2

    Endpoint functions are defined as `async def`, but the db operations inside are all sync, including the get_session depency. This is bad in a real project. async def endpoints are running in an event loop, time cosuming db operations are not awaited, so they will block the event loop.

    • @zoxxar
      @zoxxar 6 месяцев назад

      can you give an example of changing a DB operation to support async?

  • @recaseng
    @recaseng 5 месяцев назад

    Please do more on the crud operations as well as error handlings please

  • @ayushshende4290
    @ayushshende4290 5 месяцев назад

    A video on env config and file structure for bigger projects would also be helpful

  • @catchychazz
    @catchychazz 6 месяцев назад +1

    Is SQLModel still necessary with SQLAlchemy 2.0?

  • @kushalpy
    @kushalpy 6 месяцев назад

    Love from Nepal❤

  • @beefbox
    @beefbox 6 месяцев назад

    Hey, do you consider making an unpoly video? I feel like the library is so underrated.

    • @bugbytes3923
      @bugbytes3923  6 месяцев назад

      It has been on the list for a while, yeah. I'll try and get that done soon.

  • @djtoon8412
    @djtoon8412 6 месяцев назад

    can we also get one for microservices using gRPC

  • @AmoahDevLabs
    @AmoahDevLabs 6 месяцев назад

    great one.

  • @boholsurf_2749
    @boholsurf_2749 2 месяца назад

    great video

  • @adhd_arti
    @adhd_arti 6 месяцев назад

    Best content!

  • @farzadmf
    @farzadmf 6 месяцев назад

    Instead of converting the type to a string, you can do `from __future__ import annotations`

    • @darkbluewalther
      @darkbluewalther Месяц назад +1

      I thought too, but it actually raises an error at Runtime when trying to fetch object: sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper[Shop(shop)], expression "relationship('list[Product]')" seems to be using a generic class as the argument to relationship(); please state the generic argument using an annotation, e.g. "products: Mapped[list['Product']] = relationship()"

    • @farzadmf
      @farzadmf Месяц назад

      Weird 🤔

  • @gerrior
    @gerrior 4 месяца назад

    Timestamp: 18:30. Even after adding `None` to the `band_id` at runtime I'm getting "pydantic_core: 1 validation error for AlbumBase" "band_id missing". I am using Progres instead of SQLite.

    • @fernandohtr
      @fernandohtr 4 месяца назад

      I also had a problem around this video time. The error returned was not so clear. To solve the problem in my case, I had to transform the "album.release_date" from string to datetime.date.
      It was something more or less like this:
      if band_data.albums:
      for album in band_data.albums:
      raw_album_date = album.release_date.split("-")
      year = int(raw_album_date[0])
      month = int(raw_album_date[1])
      day = int(raw_album_date[2])

      album_date = date(year, month, day)

      album_obj = Album(
      title=album.title,
      release_date=album_date,
      band=band
      )
      session.add(album_obj)

    • @Ceddybaer
      @Ceddybaer 4 месяца назад +3

      I ran into the same issue on SQLite. I fixed it by adding "default=None" to the parameters of Field().

    • @thierryyolepiot9951
      @thierryyolepiot9951 4 месяца назад +1

      @@Ceddybaer I added "default=None" to the parameters of Field() on line 23, ie
      band_id: int | None = Field(default=None, foreign_key="band.id")
      But the error still remains

    • @subz424
      @subz424 2 месяца назад

      @@Ceddybaer Nice! I like this solution, thank you 😃.

  • @fazlehadiazmat7g803
    @fazlehadiazmat7g803 3 месяца назад

    dyed your hair?

  • @shahriarahmed9387
    @shahriarahmed9387 14 дней назад

    raise ValueError(f"{type_} has no matching SQLAlchemy type")
    ValueError: has no matching SQLAlchemy type

  • @alexandrodisla6285
    @alexandrodisla6285 6 месяцев назад +1

    restAPI,sqlmodel,alembic. docker .compose and metrics

    • @bugbytes3923
      @bugbytes3923  6 месяцев назад +1

      Alembic + FastAPI + SQLModel early this week! Thanks.