Skip to main content
7 votes
Accepted

SQLAlchemy and DDD: It's own pattern?

This is a common issue, and the cause is usually related to a shallow understanding of DDD. The purpose of DDD is to model the functional requirements of your system such that the result is a useful ...
user3347715's user avatar
  • 3,244
5 votes
Accepted

When using an ORM when should I sacrifice performance for convenience?

The way you make this decision is by optimizing when you need to. There are many scenarios (e.g. a single-record data-entry form) where pulling all of the fields is perfectly acceptable, since you're ...
Robert Harvey's user avatar
4 votes
Accepted

Should integration tests of a repository pattern use low-level ORM calls

These tests sounds like data mappings tests. I do this frequently, too, with NHiberate (an ORM for .NET). What you describe are perfectly valid tests. Beware that ORMs may have multiple layers of ...
Greg Burghardt's user avatar
4 votes
Accepted

Maintaining parallel libraries: Binary files access + Metadata Database ORM design

Take a step back. If there is something in common between the two API's then they are discussing the same thing. You can extract that sameness into a library which is expanded on by the ...
Kain0_0's user avatar
  • 16.6k
4 votes

Separate business logic from ORM models in SQLAlchemy

If you really want to decouple your persistence layer from your domain logic, you could use plain old python objects as domain objects and the "models" only for persistence. You could ...
Thomas Junk's user avatar
  • 9,623
3 votes

How to Design a Database for Both Flexibility and Data Isolation?

This is a tool problem. Automating schema changes will be more beneficial here. Depending on laws in whatever country your application is used, data isolation may practically be mandatory. Instead, ...
Greg Burghardt's user avatar
2 votes
Accepted

How to organize ORM models and business logic

When trying to solve a problem like this, it is important to know the constraints that your current design has. SQLAlchemy seems to be an implementation of the Active Record Pattern, which combines ...
Greg Burghardt's user avatar
2 votes
Accepted

SQLAlchemy (ORM) details in service layer in Clean Architecture?

I'm not sure where the dilemma is. Of course the repository should encapsulate the options and anything else database related. Returning only fully populated domain objects.
Ewan's user avatar
  • 84.6k
2 votes

Splitting up large SQLAlchemy model

single responsibility I'm accustomed to seeing lots of SqlAlchemy model classes that are narrowly focused on representing rows and on relational integrity (like foreign keys). Such classes will only ...
J_H's user avatar
  • 7,997
1 vote

Splitting up large SQLAlchemy model

IMO the frame of mind you could have going into this refactor is: "the SQL Alchemy model is responsible for just two things: (1) CRUD DB operations, and (2) validation: ensuring its data is ...
Dogweather's user avatar
1 vote

Separate business logic from ORM models in SQLAlchemy

I have used this pattern in the past with flask but I think there are a number of issues with your implementation; I think it's better to know the model directly from the class, as this enable you ...
user93778334433's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible