On Mar 12, 7:49 pm, rev <[email protected]> wrote:
> This is indeed a one time import, so performance is not really an
> issue.
> Would like to know about other approaches though, to learn from.
Probably the main optimisation would be to bypass the User and Group
objects entirely. You seem to have all the id values you need to
insert rows into the user_group_table, so collecting them up into
insert statements would presumably do the job. If you'd prefer to
avoid raw SQL then some variation on the following may work:
membership_list = []
for group in groups:
for member in group.members:
membership_list.append( { 'user_id': member.id,
'group_id': group.id } )
DBSession.execute(user_group_table.insert(), membership_list)
See the following link for the reference I based this on:
http://www.sqlalchemy.org/docs/05/sqlexpression.html#executing-multiple-statements
--
Ben Sizer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---