Re: [sqlalchemy] mapping postgres sequences?

2012-05-29 Thread Robert Forkel
example now includes your second question: from sqlalchemy import Sequence, create_engine, MetaData, Column, Integer from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Model(Base): __tablename__ = 'model' col = Column(Integer, Sequence('seq'), prima

Re: [sqlalchemy] mapping postgres sequences?

2012-05-29 Thread Robert Forkel
working example for the first question: from sqlalchemy import Sequence, create_engine, MetaData if __name__ == "__main__": md = MetaData() e = create_engine('postgresql://rforkel@/test1', echo=True) md.bind = e s = Sequence('name', metadata=md) md.create_all() print list(

Re: [sqlalchemy] mapping postgres sequences?

2012-05-29 Thread Robert Forkel
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(s

[sqlalchemy] mapping postgres sequences?

2012-05-29 Thread Chris Withers
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 Con