Sequence has a create() method but doesn't yet link into metadata.create_all()
without being assocaited with a Table. So yes you'd use DDL or in 0.6 the
CreateSequence() construct.
On Apr 20, 2010, at 7:26 PM, Wichert Akkerman wrote:
> What is the preferred method to have metadata.create_all() create sequences?
> I tried to find something in the wiki but could not find anything. For
> indexes you can do this:
>
> schema.Index("public_event_idx", Event.workflow, Event.deleted)
>
> but a similar statement for a sequence:
>
> schema.Sequence("invoice_number", metadata=meta.metadata)
>
> does not do anything. From what I gather from the source Sequence is not
> derived from SchemaItem, so it is not picked up automatically. I could do a
> DDL construct like this (untested, but basic idea should work):
>
> from sqlalchemy.schema import DDL
> def sequenceSupported(event, schema_item, connection):
>return connection.dialect.sequence_supported:
>
> DDL("CREATE SEQUENCE invoice_number", on=sequenceSupported)\
>.execute_at("after-create", metadata)
>
> but I would rather not have to hardcode the SQL statement, especially
> since SQLAlchemy is capable of generating the statement as well.
>
> Wichert.
>
> --
> Wichert AkkermanIt is simple to make things.
> http://www.wiggy.net/ It is hard to make things simple.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@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.
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.