Blending SQL and Python with Sqlorm
Key topics
The article introduces Sqlorm, a library that blends SQL and Python, allowing developers to keep SQL explicit while still getting ORM conveniences. The discussion revolves around the trade-offs between raw SQL, ORMs, and Sqlorm, with users sharing their experiences and preferences.
Snapshot generated from the HN discussion
Discussion Activity
Moderate engagementFirst comment
9m
Peak period
7
96-108h
Avg / period
3.3
Based on 10 loaded comments
Key moments
- 01Story posted
Nov 11, 2025 at 4:53 AM EST
about 2 months ago
Step 01 - 02First comment
Nov 11, 2025 at 5:02 AM EST
9m after posting
Step 02 - 03Peak activity
7 comments in 96-108h
Hottest window of the conversation
Step 03 - 04Latest activity
Nov 15, 2025 at 11:59 AM EST
about 2 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
https://nl1.outband.net/fossil/query/file?name=query.py&ci=t...
In short you have your query in file sql/dept_personal.sql and you call it like
Because their lists don't have selection by bare words, they have to go one of several other specialized, distinct, built-in Abstract Data Types to get it. They have to create whole so-called "Classes" and "Modules", when all they really needed was a list whose elements can be accessed with a dot and a bare word.
The pandas package for tabular data manipulation requires even more complicated workarounds. It has a DataFrame Class composed of objects of Column Class. Then it makes an arbitrary bunch of common functions, so common that many are built into Python itself, Methods of said Columns. (In R, a table is just a list of vectors, and no Methods are needed.)
So now you've got a thing that's supposedly a real Class, but it's really just a container of completely arbitrary fields and data types. These fields are themselves instances of another Class that is supposedly specific to pandas, but is really just a vector, and a vector doesn't necessarily have anything to do with being part of a table. And that Class has some random methods that give you additional ways to do basic things the language already does, and are often not the functions you actually need to work with the data therein.
All that just so that we can write stuff like df.col.max(), and... gosh, what is that even supposed to mean? Can we all just admit that we like writing code in chains separated by dots, and stop tying that capability to hierarchies of Official Abstract Data Types?
These non-R languages make you utter such strange incantations just to put something in a key-value container and access that thing with nice-looking code. I feel like this makes it harder to realize that very often this is the best way of doing things.
R has a bit more varied and sometimes mildly ugly syntax than other languages, but once you get used to the building blocks it gives you, it has all these powers to do very dynamic things in very easy ways, without a bunch of ponderous specialized concepts.
I feel the same, hence why I prefer a Django-like ORM to SQLAlchemy in spite of all the praises it gets. The author says "SQLAlchemy is the best. I don't like the API or codebase of the others", but actually what he describes feels like the Django ORM (or Tortoise, or many others).
Also, sometimes just a thin layer above SQL is fine. For small personal projects I use my own wrapper above sqlite like so:
Your pattern of re-interpreting __doc__ is kinda weird though. Why not just add a `return` statement?
So I made a very simple module that takes those sql files and turns them into SQLAlchemy text objects with variables in them.
Would it be possible to add something like this to the project or does it require many sql parsing libraries etc. to ensure sql validity to find variables in the sql file?
15 more comments available on Hacker News