`.get()` returns the corresponding row/object based on the primary key https://docs.sqlalchemy.org/en/13/orm/query.html?highlight=get#sqlalchemy.orm.query.Query.get
assuming `PermissionEntity` has a primary key of (permission_id, contact_id), the syntax from the examples would be: some_object = session.query(VersionedFoo).get((5, 10)) or my_object = query.get((5, 10)) If you have another primary key, you'd have to filter: some_object = session.query(PermissionEntity).filter(PermissionEntity.permission_id==2, PermissionEntity.contract_id==2).first() or some_object = session.query(PermissionEntity).filter_by(permission_id==2, contract_id==2).first() On Thursday, May 28, 2020 at 11:15:38 AM UTC-4, Tanjil Hussain wrote: > > [image: Capture.PNG] > > permission_id and contract_id have a relationship in the database > > How can i using remove a entry for example.. if permission_id = 2 and > contract_id = 2 exists in the same entry as shown on line one in database, > i want to be able to remove it from my database. (This entry is unique so > can only appear once) > > I have tried PermissionEntity.query.get(contract_id) and > PermissionEntity.query.get(permission_id) but doesnt seem to be working > as Its not stored in a permission entity.. My relationship does not have an > entity. the table i have provided a picture for has a relationship with > permissions table and contracts table.. > > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/f095a379-1e2e-42c3-89b1-d739de014086%40googlegroups.com.