Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_instance(self, data):
"""Retrieve an existing record by primary key(s)."""
props = get_primary_keys(self.opts.model)
filters = {
prop.key: data.get(prop.key)
for prop in props
}
if None not in filters.values():
return self.session.query(
self.opts.model
).filter_by(
**filters
).first()
return None