Simon Willison’s Weblog

Subscribe

Monday, 25th March 2024

sqlite-schema-diagram.sql (via) A SQLite SQL query that directly returns a GraphViz definition that renders a diagram of the database schema, by Tim Allen.

The SQL is beautifully commented. It works as a big set of UNION ALL statements against queries that join data from pragma_table_list(), pragma_table_info() and pragma_foreign_key_list().

# 5:12 am

Them: Can you just quickly pull this data for me?

Me: Sure, let me just:

SELECT * FROM some_ideal_clean_and_pristine.table_that_you_think_exists

Seth Rosen

# 11:33 pm / sql, analytics