Michael Bayer wrote: > Sebastian Elsner wrote: >> Hello, >> >> I have an association object declaratively with three primary keys, but >> on >> insert, the first (id) is not autoincremented. Please see test the code >> below > > known sqlite limitation, described at > > http://www.sqlalchemy.org/docs/reference/dialects/sqlite.html?highlight=sqlite#auto-incrementing-beahvior
spelling correction: http://www.sqlalchemy.org/docs/reference/dialects/sqlite.html?highlight=sqlite#auto-incrementing-behavior > >> >> >> >> >> from sqlalchemy import create_engine, Column,Integer, String, >> ForeignKey >> from sqlalchemy.ext.declarative import declarative_base >> from sqlalchemy.orm import sessionmaker,relation, backref >> >> engine = create_engine("sqlite:///:memory:",echo=False) >> Base=declarative_base() >> >> >> class Child(Base): >> >> __tablename__="Child" >> >> id=Column(Integer,primary_key=True) >> >> class Association(Base): >> >> __tablename__="Association" >> >> id=Column(Integer,primary_key=True) >> >> parent_id=Column(Integer,ForeignKey("Parent.id"),primary_key=True) >> child_id=Column(Integer,ForeignKey("Child.id"),primary_key=True) >> >> child=relation(Child,backref="parents") >> >> data=Column(String(32)) >> >> def __init__(self): >> self.data="some text" >> >> class Parent(Base): >> __tablename__="Parent" >> >> id=Column(Integer, primary_key=True) >> >> children=relation(Association,backref=backref("parent")) >> >> Base.metadata.create_all(engine) >> Session=sessionmaker(bind=engine) >> session = Session() >> >> p=Parent() >> a=Association() >> a.child=Child() >> p.children.append(a) >> >> session.add(p) >> session.query(Parent).all() >> >> >> I need the id for another 1:n realtion with the association object. What >> am I missing here? >> >> >> Thanks >> >> Sebastian >> >> -- >> 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. > > -- 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.