1from sqlalchemy import Column
2from sqlalchemy import Integer
3from sqlalchemy import String
4from sqlalchemy.orm import registry
5from sqlalchemy.sql.schema import ForeignKey
6from sqlalchemy.sql.schema import MetaData
7from sqlalchemy.sql.schema import Table
8
9
10reg: registry = registry()
11
12
13@reg.mapped
14class Foo:
15    __tablename__ = "foo"
16    id: int = Column(Integer(), primary_key=True)
17    name: str = Column(String)
18
19
20@reg.mapped
21class Bar(Foo):
22    __tablename__ = "bar"
23    id: int = Column(ForeignKey("foo.id"), primary_key=True)
24
25
26@reg.mapped
27class Bat(Foo):
28    pass
29
30
31m1: MetaData = reg.metadata
32
33t1: Table = Foo.__table__
34
35t2: Table = Bar.__table__
36
37t3: Table = Bat.__table__
38