Это видео недоступно.
Сожалеем об этом.
Creating Many-To-Many Relationships in Flask-SQLAlchemy
HTML-код
- Опубликовано: 4 янв 2022
- I talk about how to use Flask-SQLAlchemy to create many-to-many relationships between tables.
Need one-on-one help with your project? I can help through my coaching program. Learn more here: prettyprinted....
Join my free course on the basics of Flask-SQLAlchemy: prettyprinted....
Get the code here: prettyprinted....
Twitter: / pretty_printed
Github: github.com/pre...
Small token for all the help you've provided over the years. Thank you again!
Probably the best explanation on Many-to-many relationships! Thanks!
Couldn't have said it any better. Thank you Anthony
Anthony did not hesistate to make this video, all was fluently... Thanks!
man, that was pricise.
Thanks buddy
Thank you for your videos, it helped me create relation for student and enrolled courses, so now the challenge is to add third entity which is time table allocated for each course and figure out conflict if any !!, wish me luck
THANK YOU! I have spent hours and hours trying to figure this out! I wish I would have found your video sooner! I was close by help of stack overflow but still not quite there. Such good explanation as well! I thank you again. Keep up the great content!
Your vids are great, thanks a lot for all of them! Any chance you can upload a video about a Many-to-Many table with additional fields? I think it is called an association object.
Thanks!
Thank you for this helpful explanation of many to many relationships.
Wow! I like your way to explained, is very easy to understand, thank you so much!!
0:58 I wish the part about having other attributes in the relationship table is featured here because that's what I'm confused with and I can't find any where that explains it. This video mentioned how it's for another time but that doesn't seem to happen yet.
Have you found an example for a third attribute?
I want to add a permissions column to the association table where True would grant users certain rights. I've been able to add another column to association table but not yet edit it.
You shouldn't explain this well mahn😆, perfect stuff
I watched the one to many, which you explained super well. I have quit this video less than halfway coz I already understand it following the one to many video. Thanks a lot mahn.
This is GOLD! Thank you 😀
thanks for the service man, appreciate it
Please, make a tutorial for foreign key constraints in flask-sqlalchemy. There's really little info about it
Hello... will be pleased if you can do an indepth tutorial on pydantic and fastapi with sql alchemy based on relationships... I know it sounds alot... thanks cheers
How can i check if an inputted item is in say “erin.following”? I tried just doing “if input in erin.following:” and I defined Erin.following as something else but I don’t think this condition is ever being reached. As my flask app returns “view function has no return item” when this condition is suppose to be hitting. Advice?
I get it!! I finally get it ! This was the best explanation for sure
Amazingly Explained!
You're a savior, thanks!
Nice and Clean explanation 🤩
Is there an easy way to directly add rows to the association table without doing the append? Basically an INSERT to the association table with the id values. I have a large amount of data that I need to create association records for and it seems like it would be more efficient to directly add to those vs. querying the database to get objects for both sides of the association table and then linking them. Thank you for all that you do with your videos, super helpful!
oh my lord! I was looking for the exact same thing. I was hoping we could just pass it as a parameter but nope
Same code doesn't work for me...
When I try to reproduce the terminal commands
It says the app context isn't defined:
This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.
Excellent video!
Very good man!
Thanks a lot!
Thank you very much
Hey Anthony, another great video! ^_^ if you don't mind me asking this but I was just checking to see if ya got any other channels but it seems you had subscriptions public so didcha subscribe all the channels by hand or used a bot or something :p . I am really curious almost if not all the programming channels are subscribed I've ever heard of XO.
I've subscribed to all of the channels myself. I'll subscribe to pretty much any channel I come across that makes programming content.
@@prettyprinted hi there, now I am officially a university student and really would have liked to explore other programming channels for different topics unfortunately you don't cover. ANYWAYS, did you remove subscriptions to all of them? It could have come in handy.
life-saver, thank you
Hi, what happen if the relationship table has another attribute (ex: is_required), how can I add the element in the table using a similar notation ex: erin.following( mrbeast, True)?. Thanks
bro it's fire, thanks a lot!
I wanted to see how u did this in flask instead of the console cause flask just says that query object has not attr 'table name'
Thank you so much
Thanx for the video I am suffering from this error "sqlalchemy.exc.ArgumentError: Mapper Mapper[User(user)] could not assemble any primary key columns for mapped table 'user'" help plss;
Is there a way to toggle in join table between users and channels? I mean if you click on some button on UI, and if there is a join between 2 entities to delete that row in the join table, otherwise to create a new record in join table? Thanks
Hi Anthony can please make a video on how to store latitude and longitude in django models, in addition to that how to query and get the top nearest entires based on some input. I found something called geodjango put its hard to understand and it have like geometry and spatial indexes. I'm a little confused which one to choose.
How do you query the table created using db.table
nice video! But does anyone know how to access the association table?
if we add fields to association table, then how to access those fields having in mind that association table has no model.
Hi is there a way to query the joins table to get all the entries inside of the joins table??
Bro you are amazing
how to add these terminal command to program, i am getting an error "object attached to a session"
Legendary!
Hey how can i use 1 sqlite db with 2 different flask web app
You're the best
Thanks for the tutorial. I have a small problem that you might help me with: I've created the users and channels as you did (e.g. anthony=User(name='Anthony') and closed VScode. When I reopened it, I imported everything (from main import db,User,Channel), but for some reason when I try to do something with the users, such as "anthony.followers.append(prettyprinted)", it returns "NameError: name 'anthony' is not defined". For some reason, variables that I created before (and exist in my database) are not received by the app if I close VScode and open it back. Can anyone help me with this problem?
When close and reopen you need to define the variables again, just execute anthony=User(name='Anthony'). Also, don't forget to commit your changes.
Thank you guys!
How can we inherit the relationships that are already defined in a db?
SQLAlchemy has the ability to autocreate models from existing database tables. Here's a video where I talk about it: ruclips.net/video/UK57IHzSh8I/видео.html
@@prettyprinted you're the greatest. It's time for you to publish a book on O'Reilly or packt.
@@chriskeo392 Maybe one day
Hey Anthony!
Can you please explain how to make this same job for 3 tables? like
table: MATCH_USER_RESOURCE
id | match_id | user_id | resource_id
apparently it only works with 2 pks
Thank you!
Short answer: You don't
What exactly do you want to achieve or to paraphrase it: What should this relationship represent?
@@historynerd6630 What if you wanna make a User table, Group table and Role table, Where there is a many to many relationship between them because a user can be a part of different groups and have a different role in each group
@@awesomedude7262 Given there are two groups (G1 and G2) and 3 possible roles (guest, user and moderator). Having a certain role in one group does not say anything about having (or not) the same role in the other group. Therefore it's globally not the same ROLE. So you could say there are actually 6 roles: guest@G1, user@G1, moderator@G1, guest@G2, user@G2 and moderator@G2 right? This could be represented by a table (ROLE_AT) with 6 rows for those 6 combinations and 3 columns: ROLE_id (primary key), GROUP, ROLE. Last thing you need is an association table for your many to many relation between USER table and ROLE_AT table.
nice video
Thanks