When using SQLAlchemy there are for example two classes describing the User and Contact tables. At the same time Contact has a connection many to one to each line on User.
class User(Base): __tablename__ = "user" id = Column(Integer, primary_key=True) name = Column(String, nullable=False, unique=True) class Contact(Base): __tablename__ = "contact" id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey('user.id')) contact = Column(String, nullable=False, unique=True)
Is it possible, and if so, how, to describe a function in the User class of type add_contact, which will add an entry to the Contact table?