I want to do a database operation where I have 2 tables (Table1 and Table2). There is an "id" column in Table1 and in table2 I have 4 column (id, server, port, endpoint). So I want to compare id of both table and if match I want server, port and endpoint details. I am using fastAPI with sqlalchemy.
Model file is something like this
#Table1
class RD(Base):
__tablename__ = "table1"
id = Column(String, unique=True, index=True, nullable=False)
#Table2
class AD(Base):
__tablename__ = "table2"
id = Column(String, unique=True, index=True, nullable=False)
server = Column(String(100), index=True, nullable=False)
port = Column(String, index=True, nullable=False)
endpoint = Column(String, index=True, nullable=False)
Now i want comapare the id's of both the table and if matched i want to print server, port and endpoint from table 2. Also i dont want to write a raw sql queries. i want to write a ORM based query.
my database connection file
Thanks.