5 ms·
I agree about Flash/Django. But SQLAlchemy is definitely not "better". It is more powerful, more correct, more proper, more flexible. But boy is it a fucking o
by njharman 9y ago
I agree about Flash/Django. But SQLAlchemy is definitely not "better". It is more powerful, more correct, more proper, more flexible. But boy is it a fucking obtuse, verbose, difficult piece of bahoo to use. Django ORM follows Django's philosophy of pragmatism. Assume sane defaults/be opinionated. Make the easy, everyday shit easy! The hard stuff can be figured out later (or just drop to raw SQL). SQLAlchemy's philosophy is to be correct, like RDBMA academic correct and proper. Make the insanely rare and/or difficult stuff possible even if it means making the common stuff a PITA.
It's like the difference between an esoteric and powerful language like Haskell which is objectively more correct. And Python, which is "who cares purity, it lets me get shit done fast and easy."
There's also, I think, a huge divide in the way developers think/reason about problems. Cause I've never seen anyone like both ORMs. Everyone likes/tolerates one and hates the other. I'm guessing some devs "think" the way SQLAlchemy works and others "think" the way DjangoORM works.
So, I do think both ORMs have their place. Just wish SQLAlchemy's place was not in code I have to write/maintain.
- scrollaway 9y agoI like both ORMs, exactly for the reasons you mention. I wish SQLalchemy had a "simple" mode that resembles the Django orm API though yeah.
- ris 9y agoI'd wager it would be possible to implement the django ORM on top of SQLAlchemy.
- vosper 9y agoI'm in the camp of liking SQLAlchemy, and not really liking Django's ORM, which I am admittedly much less familiar with. I especially find Django's functionality for aggregations to be completely arcane and a long way from the SQL that I am modeling in my head. I wonder if that's what it comes down to - as someone who tends to think in terms of the SQL I want to build I find SQLAlchemy to be a lot closer to my mental model than Django. For just getting an object by ID I don't think there's much difference, for me. I think one thing in Django's favour is that SQLAlchemy can be confusing to setup (do I need scoped sessions?). Also, you need to find and setup your own solution for migrations, whereas Django will just sort that out for you. So getting up and running is a lot easier.
- phonon 9y ago> I especially find Django's functionality for aggregations to be completely arcane and a long way from the SQL that I am modeling in my head. Do you mean https://docs.djangoproject.com/en/dev/topics/db/aggregation/ https://docs.djangoproject.com/en/dev/topics/db/aggregation/ and https://docs.djangoproject.com/en/dev/ref/contrib/postgres/aggregates/ https://docs.djangoproject.com/en/dev/ref/contrib/postgres/a... ? How would you improve it?
- ris 9y ago> But SQLAlchemy is definitely not "better". It is more powerful, more correct, more proper, more flexible. Indeed - for my purposes, it's better. But I loves me' databases. > And Python, which is "who cares purity, it lets me get shit done fast and easy." Oh - ouch. It is possible to write quite pure python, y'know. But it allows you to break the rules when purity would just lead you down very obtuse paths. Or when your code is fundamentally side-effecty.
- maweki 9y agoIt is not practical to write pure python code. There's always the implicit state of a generator so lazyness is fucked. And you don't know whether you're passed a list or a generator and then you tuple-unpack it and the generator is empty. And then, of course, you can override the dot-operator and even bare statements can have side effects. Have you ever tried to write really _pure_ python? I did and it is harder than it needs to be.
- milin 9y agoFancy seeing you here njharman. And yeah I am working with a Sqlalchemy codebase right now, and it really really makes me miss django orm.
- njharman 9y agoyo!
- flavio81 9y ago> boy is it a fucking obtuse, verbose, difficult piece of bahoo to use. I have used SQLAlchemy a lot, and find it very easy to use. I've used other ORMs as well, in other platforms. I find SQLAlchemy a very good ORM.
- bitexploder 9y agoMaybe I have programmer Stockholm syndrome, but SQLA is one of the best ORM in existence. Period. I have spent a lot of time with it. I think in terms of Python style and SQL and I think SQLA fits it better than Django ORM. Django ORM fits Django better. SQLA makes it easy to do OO style SQL modeling in a very Pythonic way. I don't hate Django ORM. If I used Django I would use the ORM it comes with. It is ok. I think data is so important I avoid Django because I think its ORM becomes the limiting factor for medium or large projects. For small projects, it hardly matters. Use what you know or has a path of least resistance for you. An aside, Pyramid is actually in between Flask and Django, but people often think it has to be Flask or Django. Pyramid is beautiful and much less opinionated than Django, but still has some batteries, or rather it supports several different types of batteries. Practical programmers don't hate tools IMO. Makes you too vulnerable to overvaluing your opinion.
- flavio81 9y agoTo be honest, SQLAlchemy was the single reason I chose to dive more into Python. I learnt it first because of being curious about it. Then, when I found SqlAlchemy, I, having had long years of using Hibernate and NHibernate, thought "if the other Python packages are as good as this one, i should use Python for serious stuff". Which I did. SQLAlchemy is damn easy to use.
- mixmastamyk 9y agoI've found sqla easy to use but it's documention is exactly how you describe. Often I have read a section a few times and still don't quite get it.