On Jan 3, 2013, at 12:51 PM, [email protected] wrote:
> Hi,
>
> I have one set of tables and I want to automate the insertion of the
> company_id in queries at certain tables. So I need to define in the models
> which tables are effected, no worries there, but where do I need to implement
> the query manipulation? The SQLAlchemy object is shared between different
> requests (as the configuration remains te same). But the session is
> different, as the company_id differs between sessions.
>
> Where and how do I implement the query manipulation?!
its not clear what usage pattern you're looking for here. Lets start with the
obvious, putting "company_id" in a query:
session.query(SomeObject).filter(SomeObject.company_id == 5)
easy enough.
Now what exactly do you want it to look like?
Like,
session_one.query(SomeClassOne) -> automatically put company_id = 8
session_two.query(SomeClassTwo) -> automatically put company_id = 15
?
if I'm given "session_one" and "SomeClassOne", what is the "company_id" for
that ?
There's a pattern for auto-querying of a certain column at
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQuery . But this
doesn't get into how to determine where the custom criterion would come from.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.