10 ms·
So much of workaday SQL stuff is handled nicely by ORMs it's hard to pass on the convenience. I've found that using the ORM in conjunction with stored procedur
by deltarholamda 4y ago
So much of workaday SQL stuff is handled nicely by ORMs it's hard to pass on the convenience.
I've found that using the ORM in conjunction with stored procedures works well. For the basic stuff, the ORM handles it well enough. As soon as the ORM request starts to look like spaghetti, it's time to think about making a stored procedure and using it.
Years ago I also went down the road of "use stored procedures for everything," which also works, but you have to get deep into the gnarly SQL weeds. And, if DB portability is one of your goals, you more or less have to give up on your dreams. It makes a lot of sense if your project has many fingers in the pie and you have access to a talented-if-grumpy DBA (beard optional). I liked it for the small project I did, but I will admit that it was more work than was optimal.
- Izkata 4y agoOr views. Django at least lets you point a model at a view and say "managed = False", then just keep using the ORM for SELECT queries.
- bb88 4y agoAt a deeper level ORMs exist because SQL isn't what people want most of the time. I think it's ironic that with databases and hardware description languages, we have been stuck in the 1990s with just one or two selections. In regular software development we have maybe 500 languages that large systems have been built from. ORM's are language abstractions that compiles down to SQL. With HDL's we have VHDL and Verilog. The other HDL's that are built on Python/Scala compile down to VHDL and Verilog, just like the ORM's compile down to SQL.
- deltarholamda 4y ago>At a deeper level ORMs exist because SQL isn't what people want most of the time. Definitely true. ORMs allow an on-rails experience for, I dunno, 80%? 85%? of what people want a DB for. The RDBMS is mostly treated as a durable storage system. The real magic of an RDBMS only comes through when you get really, really complicated, and then you need SQL to manage these complex relationships. ORMs try to make that easier, but beyond a certain level it isn't less complex, just differently complex. The ORM written in your preferred language means less context switching during development. Great idea, and a great tool.
- bb88 4y agoI think SQL is good at what it was meant to do back in the 1980s. Kind of the same way C was for systems programming, and is still good for many things today. In those two instances I mentioned, there's this weird ideology usually in the form of "just learn SQL/Verilog/thing here" -- while ignoring basic inefficiencies of those languages. No one bothers to say "Just learn C and all your problems will be solved" because I think everyone understands all the inefficiencies that C has. Though there are other proponents of other languages/frameworks that take this tack.