Simon Willison’s Weblog


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().