similar, you'd need to use sys.exc_info() and walk through the stack
trace to programmatically determine the origin of a Python statement.
You could do this inside the before_execute() event, for example.




On 01/13/2016 01:31 PM, Richard Gerd Kuesters wrote:
> Mike, thanks for your attention and i'm sorry, i was not clear enough in
> my question.
> 
> i would like to know if there's a way to tell if a query was fired by
> sqlalchemy internals or by my coded query (programatically).
> 
> 
> thanks a lot!
> richard.
> 
> On 01/13/2016 04:11 PM, Mike Bayer wrote:
>> sure, use pdb to step through and use the "where" command to show where
>> each call originates.
>>
>> alternatively, if this is for profiling, you can use print_callers() as
>> in the example at
>> http://docs.sqlalchemy.org/en/rel_1_0/faq/performance.html#code-profiling 
>> which
>> will show the origins of calls, though you'd need to step through things
>> to see the full chain.  A tool like RunSnakeRun can provide a graphical
>> display instead.
>>
>>
>> On 01/13/2016 11:58 AM, Richard Gerd Kuesters wrote:
>>> hi all!
>>>
>>> i'm wondering if there's a way to determinate if a query was "launch" by
>>> my code (ex. session.query(Entity)...) or by the internals of sqlalchemy
>>> (backref, relationship, etc). i think it's better to use a example,
>>> based on *adjacency_list.py*:
>>>
>>> http://pastebin.com/q3yx36vn
>>>
>>> in the code, you'll notice there's only one query *literally* written
>>> (in the main script), but "STEP" is called more than once (by
>>> internals). my question is: can I differ between them?
>>>
>>> thanks a lot!
>>> richard.
>>>
>>> -- 
>>> 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 [email protected]
>>> <mailto:[email protected]>.
>>> To post to this group, send email to [email protected]
>>> <mailto:[email protected]>.
>>> Visit this group at https://groups.google.com/group/sqlalchemy.
>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 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 [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to