I'm really curious about how many developers primarily use raw SQL compared to relying on an ORM. My current tech stack involves Svelte for the frontend and Node/Express with Knex.js for querying, but I've been sticking with raw SQL, particularly with Better-sqlite3 for MVPs. I find Knex.js and ORMs to be cumbersome, so I've opted for raw SQL while ensuring I'm using bindings to protect against SQL injection. Also, I'm working with session-based credentials instead of JWTs for client APIs, using axios, along with CORS. What's your experience with raw SQL versus ORMs?
5 Answers
Honestly, I prefer raw SQL. I'm a big fan of Dapper because it simplifies entity mapping without all the bloated ORM overhead.
I find myself using both! Often, I resort to ORMs for simpler CRUD operations, but when it comes to more elaborate queries or bulk updates, raw SQL saves the day.
I think raw SQL has its charm! Though I appreciate the convenience of ORMs, I stick with SQL for deep control over my database interactions.
I generally stick to ORMs like Laravel’s Eloquent for most things due to type safety and convention. But I use raw SQL for more complex queries when I need more control.
It really depends on the project. For situations where performance is critical, like with complex queries in Postgres, I usually stick to raw SQL to exploit features that ORMs might not support, such as `CROSS JOIN LATERAL`. For general backend stuff, I lean towards ORMs for ease and safety.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically