I have a question if you don't mind. I worked a bit with sqlalchemy in another framework, but am new to Django and I need to implement sqlalchemy so that I can transfer my code from both frameworks. At 5:35 you have: "from app.extensions import db" Where does that come from? Every tutorial online that I've been through starts with that already importing from "extensions" but I have no idea what that refers to. Apologize if it seems like a dumb question, but I appreciate any help
Bro your content is just awesome and very useful. There are some things though I think you can improve. the voice, for example, I think it's a bit low.
Hi, thanks for the video. It is soo useful!! I only start with sqlAlchemy, what can you say about this approach? I would like to have extendable and reusable queries. def get_articles_query(self, filter_data: ArticleFilter) -> sqlalchemy.orm.query: """Get articles query with default filter""" stmt = self.session.query(Article) if filter_data.plan_id: stmt = stmt.filter(Article.plan_id == filter_data.plan_id) ... # apply a lot of filtering return stmt def get_active_articles_by_user_query(self, user: User, filter_data: ArticleFilter) -> List[Article]: """Get active articles by user""" articles = self.get_many_articles_query(filter_data) articles = articles.join(User).filter(User.user_id == user.id)).filter(Article.is_active=True) return article.all()
It was very informative, Thank you! 🤝
I have a question if you don't mind. I worked a bit with sqlalchemy in another framework, but am new to Django and I need to implement sqlalchemy so that I can transfer my code from both frameworks. At 5:35 you have: "from app.extensions import db"
Where does that come from? Every tutorial online that I've been through starts with that already importing from "extensions" but I have no idea what that refers to. Apologize if it seems like a dumb question, but I appreciate any help
Most useful
Bro your content is just awesome and very useful. There are some things though I think you can improve. the voice, for example, I think it's a bit low.
Am I hearing it wrong or is he saying Djanga instead of Django?
All I’m hearing is django’s orm beats sqlalchemy out of the water 😂
Hi, thanks for the video. It is soo useful!!
I only start with sqlAlchemy, what can you say about this approach?
I would like to have extendable and reusable queries.
def get_articles_query(self, filter_data: ArticleFilter) -> sqlalchemy.orm.query:
"""Get articles query with default filter"""
stmt = self.session.query(Article)
if filter_data.plan_id:
stmt = stmt.filter(Article.plan_id == filter_data.plan_id)
...
# apply a lot of filtering
return stmt
def get_active_articles_by_user_query(self, user: User, filter_data: ArticleFilter) -> List[Article]:
"""Get active articles by user"""
articles = self.get_many_articles_query(filter_data)
articles = articles.join(User).filter(User.user_id == user.id)).filter(Article.is_active=True)
return article.all()
stop moving here and there while explaining it shows nervousness and lack of confidence
Stop sitting behind a screen and typing.