Having a table with columns listing_ids, keys how to get listing_ids (and corresponding missing keys) where values from list_of_values do not exist in keys?
list_of_values = [key2,key3]
table
listing_id keys
424 key1
424 key2
424 key3
523 key1
2433 key2
2433 key1
53 key2
3 key3
I need to get the following a result:
listing_id keys_that_does_not_exist
523 key2
523 key3
2433 key3
53 key3
3 key2
I tried:
ids_without_keys_q = session.query(Table)\
.filter(~ exists().where(Table.key.in_(list_of_values))
I am using postgresql