I use sqlalchemy (now with sqlite, but this may change later) to create a database in which the order of attachments and therefore is important. I basically have the following:
class Message(Base): __tablename__ = 'messages' __table_args__ = {'sqlite_autoincrement':True} id = Column(Integer, primary_key=True) refs = relationship('Ref') class Ref(Base): __tablename__ = 'refs' __table_args__ = {'sqlite_autoincrement':True} id = Column(Integer, primary_key=True) message_id = Column(Integer, ForeignKey('messages.id'))
When I create a Message object and append a Ref for message.refs , I would like to be sure that when I pass this to the database, Ref will be inserted in the same order in which they appear in the list. Does sqlalchemy do this by default or do I need to clean up after every addition?
source share