4 ms·
You started with the worse ORM in existance. There are ORM with good pros/cons ratios out there. Python has espacially good ones: - Django comes with a clunky
by BiteCode_dev 3y ago
You started with the worse ORM in existance.
There are ORM with good pros/cons ratios out there. Python has espacially good ones:
- Django comes with a clunky and poor performing one, but it's very well integrated, super practical, productive and has nice ergonomics.
- Peewee gives you an ORM in a small package, which makes writing those little programs a joy when you don't need anything fancy, but feel lazy.
- SQLAlchemy requires a lot more investment, but is very flexible, generates clean SQL and has extremely correct behavior. It also exposes a lower level query builder for when you don't want the OOP paradigm and wish to express idiomatic SQL behavior, but abstracted away with Python.
This becomes a standard engineering decision, where you analyze the ROI.
- heywhatupboys 3y agoRuby on rails with active record is absoutly amazing. and anyone who hasn't tried it, haven't used a great ORM
- mikrotikker 3y agoI love it.
- cpursley 3y agoElixir’s Ecto smokes AR all day and every day. I never want to go back.
- winrid 3y agoYeah, the productivity and performance with the Django ORM is amazing. I have trouble using any other web framework now... The thing people are missing is relations. The most important aspect of your application is how data is related to each other. A good ORM makes that easy.
- thworp 3y ago+1 on that. Handling relationships like parent.child.other_children when writing your own SQL is not trivial at all.
- BiteCode_dev 3y agoIt's so nice to use, espacially in a shell. And also such a performance trap.
- winrid 3y agoYeah, but once it's a performance issue you're making $$$ and you can add some indexes or write a little SQL in the few places that need it :P
- winrid 3y agoAlso child.parents[0].user.username :)
- ttfkam 3y agoTwo join clauses in a statement is not trivial? We apparently have different definitions for "trivial". But if you want hierarchy (in Postgres), to_jsonb(…) is your friend.
- winrid 3y agoIt's much, much slower productivity wise than using the orm. Like 10x slower. Why TF would I use json? There's a reason I picked a relational database. Nonsense.
- bakuninsbart 3y agoI absolutely hated having to deal with SQLAlchemy. It took me days to get through the ugly documentation to a level where I could more or less competently use it, and for what? The code is harder to understand than just writing SQL and the performance is worse. I have yet to learn of a single advantage of ORMs that don't boil down to developers not wanting to deal with SQL.
- strangetortoise 3y agoCurrently have to use sqlalchemy on an existing project, and while I am not necessarily disagreeing with you on ORMs or performance, just wanted to add that chatgpt has been able to reduce my time fighting with their documentation by what I estimate of 90+%. To be fair, if I would have written pure sql, I might not have needed chatgpt at all, but i also would have to learn pythons database connector calls for the umpteenth time.
- ttfkam 3y agoChatGPT can write SQL too.
- JodieBenitez 3y agoDoctrine sucks too. Glad I'm using Django.