sqlite-to-erd
Convert SQLite database schemas into Entity Relationship Diagrams (ERDs) using GraphViz.
Features
- 📊 Visualize SQLite database schemas as ERDs
- 🔗 Automatic foreign key relationship detection
- 📐 Two rendering modes: HTML-like tables or simple boxes
- 🖼️ Direct PNG generation with
--pngflag - 🔒 Read-only database access for safety
Installation
Option 1: Run directly with uvx (recommended)
Requires Python 3.12+ and uvx.
# Install GraphViz (required for image generation)
# macOS: brew install graphviz
# Ubuntu: sudo apt-get install graphviz
# Windows: https://graphviz.org/download/
# Run directly from PyPI without installing
uvx sqlite-to-erd database.db
Option 2: Local installation
# Clone the repository
git clone https://github.com/knowsuchagency/sqlite-to-erd.git
cd sqlite-to-erd
# Install dependencies
uv sync
# Install GraphViz (for image generation)
# macOS: brew install graphviz
# Ubuntu: sudo apt-get install graphviz
# Windows: https://graphviz.org/download/
Usage
Basic Usage
With uvx (run directly from PyPI):
# Generate DOT format output
uvx sqlite-to-erd database.db
# Generate PNG directly
uvx sqlite-to-erd database.db --png schema.png
# Use simple box format instead of HTML tables
uvx sqlite-to-erd database.db --simple
With local installation:
# Generate DOT format output
uv run sqlite_to_erd.py database.db
# Generate PNG directly
uv run sqlite_to_erd.py database.db --png schema.png
# Pipe to GraphViz for other formats
uv run sqlite_to_erd.py database.db | dot -Tsvg -o schema.svg
# Use simple box format instead of HTML tables
uv run sqlite_to_erd.py database.db --simple
# Combine options
uv run sqlite_to_erd.py database.db --simple --png simple_schema.png
Quick Examples
# Test with included examples
just fk-png # Creates test_fk.png
just complex-png # Creates complex_test.png
Output Format
The tool generates GraphViz DOT format, which can be:
- Piped to
dot,neato,fdp, etc. for different layouts - Exported to PNG, SVG, PDF, and other formats
- Edited manually for fine-tuning
Examples
Simple Database
echo "
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE posts (
id INTEGER PRIMARY KEY,
user_id INTEGER,
title TEXT,
FOREIGN KEY (user_id) REFERENCES users(id)
);
" | sqlite3 blog.db
# With uvx
uvx sqlite-to-erd blog.db --png blog.png
# Or with local installation
uv run sqlite_to_erd.py blog.db --png blog.png
Development
# Run tests
just fk # Test foreign key visualization
just complex # Test complex schema
# Generate test images
just fk-png
just complex-png
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Pull requests welcome! Please test your changes with the included test databases.
Metadata
Release files for sqlite-to-erd 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sqlite_to_erd-0.6.0.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sqlite_to_erd-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / sqlite_to_erd-0.6.0.tar.gz
| Download URL | sqlite_to_erd-0.6.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1880fb392019386b0d4c0254c9ea54a93dc75422231d2151455ca116cdc44d5d
|
|
BLAKE2b-256 checksum How to use checksums |
885c145e47c18fae0ba16a564f9f9a465f4517f36213bad4f401d50fe49addd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.14
|
Release files / sqlite_to_erd-0.6.0-py3-none-any.whl
| Download URL | sqlite_to_erd-0.6.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9e75afb96f4b834c3da2b4ddcc29feadfc89e66b8560f9caec889f5d5cea795
|
|
BLAKE2b-256 checksum How to use checksums |
04fec337c4cda18a005223e82c43b8e60adca61ec1f862f985905c952476e199
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.14
|
Security for sqlite-to-erd 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.