For context:
In a program that uses a database, writing SQL queries by hand is frequently tedious and time consuming. The "context switch" between a modern language and SQL is often difficult to navigate. Constructing objects from query results is often time consuming and boring.
ORMs attempt to solve this by wrapping SQL as a library in the programming language, yet they introduce their own problems: They can be CPU intense, generate inefficient queries, create the 1-to-N problem, or create Cartesian explosion. They are however, a godsend in large projects or when working with complicated schemas, because in the hands of a competent engineer, they can save a lot of time even though they aren't as performant as manual SQL.
As a result, in large projects manual SQL is usually relegated to performance sensitive corner cases, and/or to work around limitations of the ORM. Otherwise, manual SQL is primarily limited to small projects or projects with a very simple schema.
Getting back to the point:
One of the things AI is good at is writing tedious and time consuming "mindless" code, and handling the context switch between different languages.
This makes me wonder, when working with AI, is an ORM still worth it? Is anyone having their AI write manual SQL instead of having it work through an ORM? Is anyone using an AI to eliminate there ORM completely? I'd love to hear your experiences!
delaminator•1h ago
I did build a natural language to query, AI using Claude.
where you can go "which is our top selling product in Africa for 2025" and it will build the query for you live in a web browser, execute it and then show you the results.
The good thing about that you don't have to give the AI your actual sales figures, so you can't leak it.