👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I have the following SQLAlchemy mapped classes:
class User(Base):
__tablename__ = "users"
email = Column(String, primary_key=True)
name = Column(String)
class Document(Base):
__tablename__ = "documents"
name = Column(String, primary_key=True)
author = Column(String, ForeignKey("users.email"))
class DocumentsPermissions(Base):
__tablename__ = "documents_permissions"
readAllowed = Column(Boolean)
writeAllowed = Column(Boolean)
document = Column(String, ForeignKey("documents.name"))
I need to get a table like this for user.email = "[email protected]"
:
email | name | document_name | document_readAllowed | document_writeAllowed
How can it be made using one query request for SQLAlchemy? The code below does not work for me:
result = session.query(User, Document, DocumentPermission).filter_by(email = "[email protected]").all()
Thanks,
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from sqlalchemy: how to join several tables by one query?, check other code Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano sqlalchemy: how to join several tables by one query?
- Deutsch sqlalchemy: how to join several tables by one query?
- Français sqlalchemy: how to join several tables by one query?
- Español sqlalchemy: how to join several tables by one query?
- Türk sqlalchemy: how to join several tables by one query?
- Русский sqlalchemy: how to join several tables by one query?
- Português sqlalchemy: how to join several tables by one query?
- Polski sqlalchemy: how to join several tables by one query?
- Nederlandse sqlalchemy: how to join several tables by one query?
- 中文 sqlalchemy: how to join several tables by one query?
- 한국어 sqlalchemy: how to join several tables by one query?
- 日本語 sqlalchemy: how to join several tables by one query?
- हिन्दी sqlalchemy: how to join several tables by one query?
Tallinn | 2023-03-22
Thanks for explaining! I was stuck with sqlalchemy: how to join several tables by one query? for some hours, finally got it done 🤗. Will get back tomorrow with feedback
London | 2023-03-22
Thanks for explaining! I was stuck with sqlalchemy: how to join several tables by one query? for some hours, finally got it done 🤗. Will get back tomorrow with feedback
Warsaw | 2023-03-22
I was preparing for my coding interview, thanks for clarifying this - sqlalchemy: how to join several tables by one query? in Python is not the simplest one. Checked yesterday, it works!