On Jun 30, 4:41 pm, SamDonaldson <[EMAIL PROTECTED]> wrote:
> I wrote a custom query and selected a few columns out of a table. I
> then wanted to 'instantiatize' it so that i could reference the
> attributes as an object so I did that by calling the constructor of
> the sqlalchemy class that maps to the table. Now, I believe, since
> these classes were instantiated, sqlalchemy will try to force commit
> them at the end of the session.
not at all. SA doesnt do anything automatic in this regard; only if
you say session.flush().
however: i am under the impression that Turbogears issues an explicit
SessionTransaction for every controller method. if so, this action
*will* issue a flush() for every controller request. so this would be
because thats how TG does it, via closing their SessionTransaction.
Pylons doesnt do anything like this..its much less opinionated.
that, combined with the other thing i noticed the other day about TG,
that it appears that they are binding their metadata to a connection
completely distinct from the one they bind their SessionTransaction
to, is generally disastrous for a straight SQL statement like
table.update(). your update() statement didnt participiate in the
transaction and was hung on a table lock.
> I called
> sqlalchemy.clear_mappers(), and called session.clear() and it worked
> fine since then. Any ideas why it worked?
neither of these operations should have any effect on database locks.
its possible that some objects hanging around in the session, or some
mappers, resulted in an access to the table which you were trying to
update that then locked the row you were going for.
from what i was reading the other day, it seems like TG's integration
with SA is still largely based on SA's 0.1 behavior...and hasnt been
updated too much to deal with the non-threadlocalness of connections/
transactions. using the "threadlocal" option to create_engine() might
smooth these issues over when using TG.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---