Metadata-Version: 2.4
Name: sqlite-to-erd
Version: 0.3.0
Summary: Generate ERD diagrams from SQLite databases
Author-email: Stephan Fitzpatrick <your-email@example.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/yourusername/sqlite-to-erd
Project-URL: Repository, https://github.com/yourusername/sqlite-to-erd.git
Project-URL: Issues, https://github.com/yourusername/sqlite-to-erd/issues
Keywords: sqlite,erd,database,visualization,graphviz,diagram
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.2.1
Dynamic: license-file

# 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 `--png` flag
- 🔒 Read-only database access for safety

## Installation

Requires Python 3.12+ and [uv](https://github.com/astral-sh/uv).

```bash
# Clone the repository
git clone https://github.com/yourusername/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

```bash
# Generate DOT format output
uv run sqlite_to_erd.py database.db

# Generate PNG directly (new!)
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

```bash
# 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
```bash
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

uv run sqlite_to_erd.py blog.db --png blog.png
```

## Development

```bash
# 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](LICENSE) file for details.

## Contributing

Pull requests welcome! Please test your changes with the included test databases.
