On Feb 3, 2012, at 6:24 PM, Michael Hipp wrote:

> Is there an example or other explanation of how to use a SEQUENCE that is not 
> a primary key on a table, particularly how to create the sequence, get next 
> value, reset seq, etc. I see the base docs here, but it's not obvious to me 
> how exactly to use this class.
> 
> http://docs.sqlalchemy.org/en/latest/core/schema.html#sqlalchemy.schema.Sequence

the sequence is created on the Python side given a name:

mysequence = Sequence("mysequence")

so the docstrings list out "create()", used as such:

mysequence.create(engine)

emits CREATE SEQUENCE

and next_value(), returns a func element which can be executed:

engine.execute(mysequence.next_value())

there's not a built in feature for RESET or other alterations of sequences 
right now, you'd have to execute() the appropriate SQL for your target backend.


-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to