ad 1)
from http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#defining-sequences :
The Sequence object also has the ability to be executed standalone
like a SQL expression, which has the effect of calling its “next
value” function:
seq = Sequence('some_sequence')
nextid = connection.execute(seq)
ad 2)
i determine sequences from models by inspection:
from sqlalchemy import Sequence
...
if len(table.primary_key.columns) == 1:
pk = list(table.primary_key.columns)[0]
if isinstance(pk.default, Sequence):
...
On Tue, May 29, 2012 at 8:58 AM, Chris Withers <[email protected]> wrote:
> Hi All,
>
> How do I create a postgres sequence independent of a table using sqlalchemy?
>
> How do I select the next value from a sequence that forms part of a postgres
> table, starting with the SQLAlchemy Table object?
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Batch Processing & Python Consulting
> - http://www.simplistix.co.uk
>
> --
> 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.
>
--
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.