Open AdrianB-sovo opened 1 year ago
as far as i know the only alternative is to have your domain model classes become sqlalchemy classes, effectively tightly coupling your domain with sqlalchemy. so as always, it's a trade-off...
nice to see the classical mappers still exist in v2 tho, i was worried they were gone completely. i should upgrade....
The data class might be dataclass, attrs or pydantic, all are more general and framework independent, easy to write business logic with or without sqlalchemy or even relational database.
In chapter 02, it's stated that the classical mapping is an alternative to the declarative mapping and that:
See here: https://github.com/cosmicpython/book/blob/master/chapter_02_repository.asciidoc#inverting-the-dependency-orm-depends-on-model
But, in the SQLAlchemy documentation about Imperative/Classical Mapping, the following is stated:
(Emphasis mine)
The content of this chapter should probably be modified to indicate that. Also, is there an alternative that would use the recommended Declarative mapping?