[Python] Should I expose all SQLAlchemy model classes to all my app?

Discussão em 'Python' iniciado por Stack, Julho 7, 2025.

  1. Stack

    Stack Membro Participativo

    I started using SQLAlchemy in my app. I was wondering if I should expose all Model classes to use it in all my app. It sounds to me a bad practice as you add an "hard dependency".

    So I was thinking to create an intermediary class to do basic CRUD operation (create_object1, update_object1, ...) but it sounds also quite odd too as i have function with a lot of parameter (let say I have a table with 8 columns, I will have at 4 functions with 8 parameters, and I should manage all the validation)

    Is there a good practice here? Is the usage of pydantic or marshmallow can ease the process?

    Continue reading...

Compartilhe esta Página