Questions tagged [sqlalchemy]

12 questions
6
votes
2 answers

Separate business logic from ORM models in SQLAlchemy

I have a Flask application with tens of complex models, almost all of them related to each other. A simple pseudo-schema of some of them: +----------------+ | FoodGroup | +-------+--------+ ^ | +-------+--------+ | Food …
hambos22
  • 169
4
votes
1 answer

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

I'm dealing with a higher-level data abstraction that I would appreciate some input on. I'm working on an application that uses a large data lake. The data lake is consisted of thousands of large binary files (250MB+ up to many GB each), each of…
user27886
  • 151
2
votes
2 answers

Splitting up large SQLAlchemy model

Anybody have advice on splitting up a large SQLAlchemy model into smaller parts? I have a ~2000 line model called Article that is becoming difficult to manage. We often have to scroll and scroll to find code that needs updating. It's doing four main…
caseym
  • 129
2
votes
1 answer

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

Problem summary: In an application with wrapper methods over SQLAlchemy add() and query() methods, can integration tests that use the add() method wrapper use the query() method wrapper to validate that database table attributes and relationships…
2
votes
1 answer

How to organize ORM models and business logic

I have a Python application using SQLAlchemy. It uses around 15 database tables. For example, I have an image table that lists image files manipulated by the application. Most operations involving that image have side-effects both on the filesystem…
Hey
  • 159
1
vote
0 answers

How to store articles (with text and images) in SQLAlchemy database

I'm working on a blog-like application with Flask and SQLAlchemy and I'm unsure how to store the blog posts (articles) in the database. These are going to contain text and images (placed between paragraphaphs). I expect the text to have formatting,…
1
vote
2 answers

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

I work with SQL Alchemy a lot and, as a "lazy programmer", I enjoy the convenience it offers. But the "diligent programmer" in me often worries about optimisation and the performance of the queries and more the performance of my application in…
turnip
  • 1,701
1
vote
2 answers

SQLAlchemy and DDD: It's own pattern?

While reading "Patterns, Principles, and Practices of Domain-Driven Design" by Nick Tune; Scott Millett (certainly not the first book on DDD I've read) I started to understand usage of Martin Fowler's EAA patterns with DDD and with that there came a…
Roman Susi
  • 1,803
0
votes
1 answer

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

I am designing a system that serves multiple customers, providing data visualization for revenue and membership information. Currently I use a separate schema approach to isolate customer data. Each customer has their own schema with nearly…
0
votes
1 answer

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

I'm trying to decide how to hide data layer details (joinedload of sqlalchemy) in clean architecture. I have some dilemma about clean architecture. Please look at the code of some api endpoint (full code in…
0
votes
0 answers

Database-driven application. Code pattern to establish relationships

I have an application that mostly is composed of forms that create, modify, read, and deletes tables and establish relationships. I use SQLAlchemy. If, for example, I need to create an invoice and associate it to a customer and to an agent, from the…
user403463
0
votes
0 answers

Flask/SQLAlchemy Object Classes across app layers

I’m looking for advice where the business logic and data layers in a Flask/SQLAlchemy-based app all use essentially the same object class. As an example, my app includes a task scheduler. Tasks are received (from an external api) as “candidate…
nakb
  • 119