Readit News logoReadit News
sgarland commented on You Should Add Debug Views to Your DB   chrispenner.ca/posts/view... · Posted by u/ezekg
physicles · 2 days ago
Are there good tools that can dump a database schema to files that are human- and AI-readable?

We use migrations as the source of truth for the prod database schema, but they’re also a pain when you want to just see the latest version of a table or a stored procedure.

sgarland · 2 days ago
mysqldump --nodata

pg_dump --schema-only

Read tool docs for other options, like restricting to a specific DB or table, but that’s the basic gist of it.

sgarland commented on Go is still not good   blog.habets.se/2025/07/Go... · Posted by u/ustad
guappa · 2 days ago
How does this relate to the claim of the parent comment that cyclic structures are never freed in python (which is false, btw)?
sgarland · 2 days ago
When I replied, the only thing the comment said was “yeah no.” I was agreeing that __del__ is fraught with peril.

Reading: cyclic GC, yes, the section I linked explicitly discusses that problem, and how it’s solved.

sgarland commented on Go is still not good   blog.habets.se/2025/07/Go... · Posted by u/ustad
baq · 2 days ago
> Though Python is almost entirely refcounted, so one can pretty much rely on the __del__ finalizer being called.

yeah no. you need an acyclic structure to maybe guarantee this, in CPython. other Python implementations are more normal in that you shouldn't rely on finalizers at all.

sgarland · 2 days ago
I love Python, but the sheer number of caveats and warnings for __del__ makes me question if this person has ever read the docs [0]. My favorite WTF:

> It is possible (though not recommended!) for the __del__() method to postpone destruction of the instance by creating a new reference to it. This is called object resurrection.

[0]: https://docs.python.org/3/reference/datamodel.html#object.__...

sgarland commented on You Should Add Debug Views to Your DB   chrispenner.ca/posts/view... · Posted by u/ezekg
codeulike · 3 days ago
I'm trying to work out why 'views can help you see whats going on in your database' has got to the front page of HN. Is it that we've had a whole generation grow up with ORMs and so only people over 50 know how to actually use a RDBMS?
sgarland · 3 days ago
Not over 50, but yes. People are deathly afraid of using RDBMS features, like triggers, events, etc.
sgarland commented on You Should Add Debug Views to Your DB   chrispenner.ca/posts/view... · Posted by u/ezekg
Ozzie_osman · 3 days ago
Or write the query as a function in code, that way, everyone can know it exists, call it easily, and change it along with any other changes to your logic or schema.
sgarland · 3 days ago
So now you have to launch a special debug instance of your app that doesn't accept prod traffic, but can still connect to the prod DB, so you can shell into it and call the function?

You can and should store SQL queries in VCS. Everyone can still know that they're there.

sgarland commented on Left to Right Programming   graic.net/p/left-to-right... · Posted by u/graic
9rx · 5 days ago
Section 3.3. "SELECT" only comes first if you omit "FROM". In SQL, if it allowed, that would be something like: `SELECT table.column`.
sgarland · 5 days ago
Tuple Variables and their Range?

I don’t think I see what you see. From 3.3:

    RANGE PART P
    GET W (P.P#,P.PNAME,P.QOH):(P.QOH<25)

sgarland commented on Left to Right Programming   graic.net/p/left-to-right... · Posted by u/graic
marzell · 5 days ago
> Per the SQL standard, you can't use column aliases in WHERE clauses, because the selection (again, relational algebra) occurs before the projection.

Except this works in most major vendor SQL implementations. And they all support relation aliases in SELECT... Seems the standards have long fell behind actual implementations.

sgarland · 5 days ago
To clarify, I mean you can’t do this:

    SELECT id AS foo
    FROM MyTable
    WHERE foo = 1;
Similarly, you can’t do this:

    SELECT id
    FROM MyTable
    WHERE id = MAX(id);
Because in both cases, when the WHERE predicate is being executed, the engine doesn’t yet know what you’re asking it to find - for the former, SELECT hasn’t yet been called, so the alias isn’t applied; for the latter, the aggregation happens after filtering, so it can’t know what that maximum value is.

You can of course alias columns for SELECT however you’d like, and can also use those aliases in ORDER BY. You can also trivially refactor the above examples to use subqueries or CTEs to accomplish the goal.

sgarland commented on Left to Right Programming   graic.net/p/left-to-right... · Posted by u/graic
adwn · 5 days ago
And I'm sure there are people who program in Notepad or nano. If you want to develop software like it's the 80s again, go ahead, the rest of us appreciates at least basic IDE support.
sgarland · 5 days ago
Not liking auto-complete is a far cry from nano. I like syntax highlighting, I like on-the-fly type checking, I like linters, etc.

I use Neovim and tmux because I value snappy performance, and never having to leave the keyboard.

The reason I don’t like auto-complete is that it interrupts my thoughts. Once I’m typing code, I know what I want to do, and having things pop up is distracting. Before I’m typing, I’ll think about the problem, look at other code in the codebase, and/or read docs. None of that requires autocomplete, nor would it help me.

If you like autocomplete, great, use it, but don’t assume that it’s a binary choice between plaintext editing and Copilot.

sgarland commented on Left to Right Programming   graic.net/p/left-to-right... · Posted by u/graic
9rx · 5 days ago
Interestingly, the inventor of relational algebra for database management put the "FROM" first in his query language: https://dl.acm.org/doi/pdf/10.1145/1734714.1734718
sgarland · 5 days ago
What section did you see this? I see GET (i.e. SELECT) first.
sgarland commented on Left to Right Programming   graic.net/p/left-to-right... · Posted by u/graic
ebonnafoux · 6 days ago
The way people code with Python is by using its large ecosystem, few people only use the standart library. No one knows all the API, the more discoverability there is, the better.
sgarland · 5 days ago
I use stdlib whenever possible specifically because it’s huge, well-tested, and eliminates dependencies.

I don’t know all of its API, but I do read the docs periodically (not all of them, but I try to re-read modules I use a lot, and at least one that I don’t).

u/sgarland

KarmaCake day4257May 18, 2020
About
[ my public key: https://keybase.io/sgarland; my proof: https://keybase.io/sgarland/sigs/L3NDZjRkwP104qhB6b-hPvZp-S1y6AmlcolanYS8Vnw ]

email: <stephan@{username}.dev>

meet.hn/city/us-Charlotte

Socials: - github.com/stephanGarland

Interests: DevOps, Hardware, Databases, Open Source, Linux

---

View Original