Many to Many relationships | SQLAlchemy
HTML-код
- Опубликовано: 12 янв 2022
- In this video, I talk about many to many relationships in SQLAlchemy.
When numerous records in one table are linked to several records in another table, this is known as a many-to-many relationship.
Customers and products, for example, have a many-to-many relationship: customers can buy a variety of things, and products can be bought by a large number of customers.
In this video, I use that example to explain how many to many relationships are created in SQLAlchemy. I also demonstrate how to configure delete behavior with many to many relationships.
SUBSCRIBE:
ruclips.net/user/SsaliJonathan...
Please donate to this channel:
www.buymeacoffee.com/jod35
GITHUB:
github.com/jod35
TWITTER:
/ jod35_ Наука
thank you so much for these tutorials, they have been extremely helpful. I've been trying to understand ORM with SQLAlchemy for a couple of months now and this series is the only one I've found that explores it in a way that makes sense to me, looking forward to your other videos!
Thanks for watching.
Great Job, I'm to create my first fastapi exercises, and your videos have helped me a lot
Really glad my videos helped. Thanks for watching
perfect man, exactly that I was looking for
I am glad it helped
Thanks for the thorough explanation!
You're welcome
You made my day bro.. keep up the great work,, from Pakistan with Love!! ♥
I am really glad my video helped.
Good tutorial as always. Well done
Thanks man, I really appreciate your support.
Thanks for watching.
Greate video !! congratulations!!
Thanks for watching
Awesome. Thank you.
I’m glad it helped you
Great video, though I do have a question. Why did you use the "remove" method instead of the "delete" method that you were using in the previous videos? Is there any difference? I am referring to 30:30
According to the docs
docs.sqlalchemy.org/en/14/orm/basic_relationships.html
The way you can delete a child object from a parent is by using the remove method.
myparent.children.remove(somechild)
Você é o cara!!!
Thanks
cheers mate!
Thanks for watching
I'd like to know more about many-to-many self-relationships, such as follow and follower.
The same concept works. Though you will have primary keys of users. A very good example is found here.
blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-viii-followers
Though it is a Flask example, I hope it gives you insight
@@SsaliJonathan
This was very helpful!!
Looking forward to fastapi's video!
I've subscribed to your channel.
Thank you, what If the association table as another column instead of just two column. How do you then insert into the database?
think we can use the association table class. read about it here. docs.sqlalchemy.org/en/14/orm/basic_relationships.html#association-object
Awful mic but still you helped me a lot brother :D Thank you
Dont worry man. I got better audio and gonna release one for SQlAlchemy 2.0, Stay tuned
@@SsaliJonathan You're the best
what about if we want to create a document to each model, one to product other to customer an other to relationship, How can we avoid circular import?
So you can create your database models in a single file or create them in their own. The trick is to create your base class in a single file where they could all get it from.
Does it answer your question?
If not, kindly give me more details
Amazing tutorial bro but how make query's form this type of relationship?
You can get objects with
parent.children
This will query for the children in the relationship.