On 10/22/07, Barry Hart <[EMAIL PROTECTED]> wrote:
>
> I've written code similar to this with no problems.
>
> Are you using assign_mapper? If so, the save() call is unnecessary.
>
> Do you get this error on the first object or on some subsequent object?
>
> Barry
>
>
> ----- Original Message ----
> From: Lukasz Szybalski <[EMAIL PROTECTED]>
> To: sqlalchemy@googlegroups.com
> Sent: Monday, October 22, 2007 3:54:03 PM
> Subject: [sqlalchemy] multiple inserts of sqlalchemy instances?
>
>
> Hello,
> I need to save data multiple times in a for loop.
>
> I was trying to do something like this:
>
> You are able to select which group you want to be in: A,B,C,D....
>
> for record in userchoice:
>     new=model.User()
>     #set some variables
>   if record.group=='A':
>       #set some more fields
>       new.save()
>       new.flush()
>   elif record.group=='B':
>       #set some more fields
>       new.save()
>       new.flush()
>
> If I do that I get:
>
> File
> "/usr/lib/python2.4/site-packages/sqlalchemy/orm/mapper.py",
> line
> 838, in save_obj
>     raise exceptions.FlushError("New instance %s with identity key %s
> conflicts with persistent instance %s" %
> (mapperutil.instance_str(obj), str(instance_key),
> mapperutil.instance_str(existing)))
> FlushError: New instance [EMAIL PROTECTED] with identity key (<class
> 'XXX.model.User'>, (19527, None), None) conflicts with persistent
> instance [EMAIL PROTECTED]
>
> Is there a way to do multiple inserts with sqlalchemy?
>

I am having an issue with a second  new.flush()
Does this require multiple sessions for each save?

I can't find any documentation on multiple inserts with assign_mapper.
Lucas

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to