Michael, yes, i think the seq is automatically executed in that case.
Regarding the usage of currval i dunno. Sorry

2008/4/30, Michael Bayer <[EMAIL PROTECTED]>:
>
>
> On Apr 30, 2008, at 3:45 PM, Eric Lemoine wrote:
>
> >
> > With psycopg2, I know people using this:
> >
> > sql = "INSERT INTO \"%s\" (%s) VALUES (%s)" % (self.table, columns,
> > values)
> > cursor = db.cursor()
> > cursor.execute(str(sql), values)
> > cursor.execute("SELECT currval('%s');" % sequence_name)
> > id = cursor.fetchone()[0]
> > self.db.commit()
> >
> > I'm wondering if this is safe. And if so, if there's a way to do the
> > same with SA.
> >
>
> this is a slight bit less safe than SQLA's default practice, in the
> sense that if the application used the same connection in two
> concurrent threads (which is a bad practice in itself), the results
> may be incorrect.
>
> What I dont see above is how the sequence is getting executed.  Is the
> column a SERIAL column, and the sequence is executed automatically ?
> or is the "nextval(seqname)" embedded into the VALUES clause above
> literally ?
>
> also still curious why usage of "currval" is even needed.
>
> >
>

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