Reputation: 41
We want to apply permission on sql alchemy class. We have a table which contain mapping of user with they can access.
create table access ( user_name varchar(256), strategy_id int )
Most of our tables contain strategy_id as column. create table trade ( trade_id int, strategy_id int, .... )
Now based on the user using the sql alchemy object for trade table, I want to pass a implicit filter on each query with list of strategy_id that the user have access to.
Could you please let me know if there is a way to achieve this?
Thanks
Upvotes: 4
Views: 1265
Reputation: 21243
There is events
in Sqlalchemy Docs. This will call the function when any new case run. Like when you run the query for select, delete, update .... This may help you to create a event class which will filter all your query and add strategy_id as default in every where clause.
Upvotes: 1