Hi,
I have three tables (user, identifiers, groups) with 'many to one' and
'many to many' relationships. My code for deleting a user works
correctly but I would like to have it run faster. What improvements do
you suggest ?
<code>
def delete_list(self, user_ids):
"""Delete a list of users by id"""
session = self._get_orm_session()
for user_id in user_ids:
try:
user = session.query(User).filter(User.id ==
user_id).one()
if user:
# loop to free the user's identifiers
for ident in user.identifiers:
ident.user = None
# loop to remove the user from the groups
for group in user.groups:
del group
session.query(User).filter(User.id ==
user_id).delete()
except NoResultFound, ex:
raise SmartResourceNotFound("User not found " +
str(ex))
session.commit()
</code>
--
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.