I have two tables A and B.
I need to create a row in table B (with ForeignKey reference), after I create a new row in table A.
For example:
class A(db.Model):
__tablename__ = 'a'
id = Column(BigInteger, primary_key=True)
...
class B(db.Model):
__tablename__ = 'b'
id = Column(BigInteger, primary_key=True)
a_id = Column(BigInteger, ForeignKey('a.id'), nullable=False, index=True)
...
What is the best solution for this case in SA?
I heard about events, but can't understand how to use them the best way in this case.