Hello.
> I can guarantee you all SQL goes through the same channels.
No doubts there :-)
> perhaps you registered the event with a specific Engine or Connection that is
not the one involved in the test.
This might be it, but I don't know what should I supply instead. I have the
following setUp:
class DbTestCase(object):
def setUp(self):
self.Base = create_base()
self._create_db()
self.connection = self.engine.connect()
self.trans = self.connection.begin()
self.session = Session(bind=self.connection, autoflush=False)
self._sql_emitters = set()
event.listen(
self.engine,
"before_cursor_execute",
self._before_cursor_execute
)
I have tried every object (and its type) present in the setUp method, but all
fail with
InvalidRequestError: No such event 'before_cursor_execute' for target...
self.engine and type(self.engine) are the only two objects that event.listen is
happy with. Unfortunately NONE of them works for queries that use self.session.
I have no idea how to proceed so any help or hint is much appreciated.
Thank you in advance,
Ladislav Lenart
On 26.9.2012 16:41, Michael Bayer wrote:
>
> On Sep 26, 2012, at 5:55 AM, Ladislav Lenart wrote:
>
>> Hello.
>>
>> This is great! Unfortunately it does not work for me.
>>
>> First, the "cursor_execute" event does not exist (at least in SA 0.7.X).
>
> right, "before_cursor_execute", sorry.
>
>> I found
>> "before_cursor_execute" which has equivalent signature. I debugged it and:
>> * My callback function is successfully registered.
>> * It is called for statements like DROP TABLE, CREATE TABLE and also for each
>> select from a pg tables (I use postgres).
>> * However, it is NOT called for ANY q.all() or foo.bar where both emit SELECT
>> statements. Note that when these calls are made, the callback function that
>> worked so far is still registered...
>>
>> Do you have any idea what could be wrong?
>
> perhaps you registered the event with a specific Engine or Connection that is
> not the one involved in the test. I can guarantee you all SQL goes through
> the same channels.
--
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.