> Inside my "team" object, I go in then create the people and their
> statistics, but I don't add the people to the team collection anymore.
> The links are never used again, but it's a many-to-many relationship
> (a person can be on several teams), so I thought I needed to do this
> in order to get the many-to-many table working. Not putting these
> people in the team collections allows SQLA to free the resources.
>
> My question then becomes: how do I free up collections and have SQLA
> requery for those objects lazily?
While waiting to see if this question has an answer, I tried
circumventing the collection by directly inserting to the already
defined many-to-many table:
# This has been simplified, so don't be concerned with the odd use
# of ForeignKeyConstraint :)
team_staff = Table("TEAM_STAFF", Base.metadata,
Column("team_name", Unicode(100)),
Column("staff_name", Unicode(100)),
ForeignKeyConstraint(['team_name'], ['TEAM.name']),
ForeignKeyConstraint(['staff_name','realm', 'site'],
['STAFF.name']),
)
Database.engine.execute(team_staff.insert(), \
team_name=unicode(team_name), \
staff_name=unicode(staff_name))
Unfortunately, for Unicode names, this isn't working, and I can't seem
to coerce it to do so *sigh*. It just ends up as NULL in the DB.
I'm willing to accept any and all workarounds for this... inputting to
TEAM_CHARACTERS without having to append to a collection so it gets
freed in memory when expunge_all() is called is all I need to do! I'm
then able to sleep soundly!
Thanks all :)
Chris
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---