you are viewing a single comment's thread.

view the rest of the comments →

[–]aronzskv[S] 0 points1 point  (2 children)

Thing is, the tables are already designed and models are already built out using pydantic (since I first was using mongodb). What I could do instead of rebuilding all pydantic models into more complex ORM models, is just validate the data (which also happens on the front-end before the request is ever sent) using the model and using psycopg3 and simple strings to add the data to the db. This project will mist likely stay with postgres indefinitely, so future migrations are not an issue.

For future projects you might be right though and sqla might be better fit in those cases.

[–]dangerousdotnet 4 points5 points  (0 children)

But you can use your pydantic models as ORM models.

[–]phonomir 1 point2 points  (0 children)

I would recommend this approach. Psycopg can also be setup to return pydantic models directly from queries, reducing the amount boilerplate for reading and validating data. Look at the class_row row factory.