Код:
Код: Выделить всё
class Person(Base):
__tablename__ = 'person'
row_id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[int]
class Tables(ABC):
def print_table_column_name(self, data):
print('_table: ', self._table)
print('_col: ', self._col)
# def insert(self, data):
# return crud.insert_(self._table, self._col, data)
@property
@abstractmethod
def _table(self): pass
@property
@abstractmethod
def _col(self): pass
class PersonTable(Tables):
_table = Person
_col = Person.row_id
try = PersonTable().print_table_column_name()
Код: Выделить всё
_table:
...
self =
instance =
owner =
def __get__(
self, instance: Optional[object], owner: Any
) -> Union[InstrumentedAttribute[_T], _T]:
if instance is None:
return self
dict_ = instance_dict(instance)
> if self.impl.supports_population and self.key in dict_:
E AttributeError: 'NoneType' object has no attribute 'supports_population'
..\..\..\..\..\AppData\Roaming\Python\Python310\site-packages\sqlalchemy\orm\attributes.py:559: AttributeError
Подробнее здесь: https://stackoverflow.com/questions/792 ... rent-class