[image: Capture.PNG]
In regards to your question..I want to remove the whole relationship for 
example.. the whole first row as shown in the picture:

On Friday, May 29, 2020 at 10:21:44 PM UTC+1, Mo Hus wrote:
>
> Hey Simon , permissions has only relationship with permission_contract and 
> contract only has relationship with permission_contract ...I want to be 
> able to delete the relationship from permission_contract ...
> For example, in my permissions_contract, I may have permission_id = 1 
> which is the id taken from permissions table and on the same row have 
> contract_id = 1 which is taken from contracts table, I want to be able to 
> query permissions_contract table and check if the contract id and 
> permission id  passed to it is in the table and if so delete the 
> relationship... please advice and thanks in advance
>
> On Friday, May 29, 2020 at 7:33:22 PM UTC+1, Simon King wrote:
>>
>> It looks like you've got a many-to-many relationship between Contract and 
>> Permission, and you want to remove a Permission from a Contract (or vice 
>> versa). Is that right?
>>
>> If so, you can do something like this:
>>
>> contract = <some-contract>
>> permission = <some-permission>
>>
>> contract.permissions.remove(permission)
>>
>>
>> https://docs.sqlalchemy.org/en/13/orm/basic_relationships.html#deleting-rows-from-the-many-to-many-table
>>
>> (note that accessing "contract.permissions" will load all the permissions 
>> for that contract from the database, which might be inefficient depending 
>> on your application)
>>
>> Hope that helps,
>>
>> Simon
>>
>> On Fri, May 29, 2020 at 12:38 PM Mo Hus <teehus...@gmail.com> wrote:
>>
>>> Hey Jonathan, any luck? thanks
>>>
>>> On Thursday, May 28, 2020 at 4:15:38 PM UTC+1, Mo Hus 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 sqlal...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sqlalchemy/aac681c3-1a8f-4f99-9d0c-31ab8350518e%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/sqlalchemy/aac681c3-1a8f-4f99-9d0c-31ab8350518e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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/839cfc7d-e2b0-45d6-89c4-5bb6f4cc06b6%40googlegroups.com.

Reply via email to