# in4viz
Python library for ER diagram visualization with SVG output. Features a stencil-based architecture for flexible and customizable entity-relationship diagram generation.
## Features
- **Entity-Relationship Diagrams**: Create professional ER diagrams with tables, columns, and relationships
- **Japanese/English Support**: Full support for both logical names (Japanese) and physical names (English)
- **SVG Output**: Generate scalable vector graphics that look crisp at any size
- **Flexible Styling**: Customizable table layouts with automatic width calculation
- **Relationship Types**: Support for various cardinality types using IE notation (1, 0..1, 1..*, 0..*, etc.)
- **Auto Layout**: Smart positioning with FK relationship-aware placement
- **Type-Safe**: Full type hints for better development experience
## Installation
```bash
pip install in4viz
```
## Quick Start
```python
from in4viz import ERDiagram, Table, Column, LineType, Cardinality
# Create a new ER diagram
diagram = ERDiagram()
# Define tables
users_table = Table(
name='users',
logical_name='ユーザー',
columns=[
Column('id', 'ユーザーID', 'INT', primary_key=True, nullable=False),
Column('username', 'ユーザー名', 'VARCHAR(50)', nullable=False, index=True),
Column('email', 'メールアドレス', 'VARCHAR(100)', nullable=False, index=True),
Column('created_at', '作成日時', 'TIMESTAMP', nullable=False)
]
)
posts_table = Table(
name='posts',
logical_name='投稿',
columns=[
Column('id', '投稿ID', 'INT', primary_key=True, nullable=False),
Column('user_id', 'ユーザーID', 'INT', nullable=False, foreign_key=True),
Column('title', 'タイトル', 'VARCHAR(200)', nullable=False),
Column('content', '本文', 'TEXT', nullable=True),
]
)
# Add tables to diagram
diagram.add_table(users_table)
diagram.add_table(posts_table)
# Add relationships with cardinality
diagram.add_edge('posts', 'users', LineType.STRAIGHT, Cardinality('*', '1'))
# Generate SVG
diagram.save_svg('er_diagram.svg')
```
## API Reference
### ERDiagram
Main class for creating and managing ER diagrams.
```python
class ERDiagram:
def __init__(self, default_line_type: LineType = LineType.STRAIGHT)
def add_table(self, table: Table, x: int = None, y: int = None) -> str
def add_edge(self, from_node_id: str, to_node_id: str, line_type: LineType = None, cardinality: Cardinality = None)
def save_svg(self, output: str)
def render_svg(self) -> str
```
### Table
Represents a database table with columns.
```python
@dataclass
class Table:
name: str # Physical table name
logical_name: str # Logical table name (for display)
columns: List[Column] # List of table columns
```
### Column
Represents a table column with properties.
```python
@dataclass
class Column:
name: str # Physical column name
logical_name: str # Logical column name (for display)
type: str # Data type (e.g., 'VARCHAR(50)', 'INT')
primary_key: bool = False
nullable: bool = True
foreign_key: bool = False
index: bool = False
```
### LineType
Enumeration for relationship line styles.
```python
class LineType(Enum):
STRAIGHT = "straight" # Direct line
CRANK = "crank" # Angled line
SPLINE = "spline" # Curved line
```
### Cardinality
Defines relationship cardinality using IE notation.
```python
@dataclass
class Cardinality:
from_side: str = "1" # "1", "0..1", "1..*", "0..*"
to_side: str = "1" # "1", "0..1", "1..*", "0..*"
```
## Advanced Usage
### Custom Table Positioning
```python
# Manually position tables
diagram.add_table(users_table, x=100, y=50)
diagram.add_table(posts_table, x=400, y=50)
```
### Multiple Relationship Types
```python
# One-to-many relationship
diagram.add_edge('posts', 'users', LineType.STRAIGHT, Cardinality('*', '1'))
# Many-to-many through junction table
diagram.add_edge('post_categories', 'posts', LineType.CRANK, Cardinality('*', '1'))
diagram.add_edge('post_categories', 'categories', LineType.CRANK, Cardinality('*', '1'))
```
### Styling Features
- **Primary Key Separation**: Primary key columns are automatically separated with a horizontal line
- **NOT NULL Indicators**: Black squares indicate non-nullable columns
- **Foreign Key Markers**: "FK" labels on foreign key columns
- **Index Indicators**: "IDX" labels on indexed columns
- **Smart Layout**: Tables with FK relationships are positioned adjacently
## Requirements
- Python >= 3.8
- No external dependencies
## License
MIT License - see [LICENSE](LICENSE) file for details.
## Contributing
Contributions welcome! Please feel free to submit a Pull Request.
Raw data
{
"_id": null,
"home_page": "https://github.com/tamuto/in4viz",
"name": "in4viz",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "er-diagram, visualization, svg, database, diagram, entity-relationship",
"author": "tamuto",
"author_email": "mutomob@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b6/6f/de46b084ba116159527d41132134f6301a365c0ec07fa0b17a47b67811d5/in4viz-0.1.0.tar.gz",
"platform": null,
"description": "# in4viz\n\nPython library for ER diagram visualization with SVG output. Features a stencil-based architecture for flexible and customizable entity-relationship diagram generation.\n\n## Features\n\n- **Entity-Relationship Diagrams**: Create professional ER diagrams with tables, columns, and relationships\n- **Japanese/English Support**: Full support for both logical names (Japanese) and physical names (English)\n- **SVG Output**: Generate scalable vector graphics that look crisp at any size\n- **Flexible Styling**: Customizable table layouts with automatic width calculation\n- **Relationship Types**: Support for various cardinality types using IE notation (1, 0..1, 1..*, 0..*, etc.)\n- **Auto Layout**: Smart positioning with FK relationship-aware placement\n- **Type-Safe**: Full type hints for better development experience\n\n## Installation\n\n```bash\npip install in4viz\n```\n\n## Quick Start\n\n```python\nfrom in4viz import ERDiagram, Table, Column, LineType, Cardinality\n\n# Create a new ER diagram\ndiagram = ERDiagram()\n\n# Define tables\nusers_table = Table(\n name='users',\n logical_name='\u30e6\u30fc\u30b6\u30fc',\n columns=[\n Column('id', '\u30e6\u30fc\u30b6\u30fcID', 'INT', primary_key=True, nullable=False),\n Column('username', '\u30e6\u30fc\u30b6\u30fc\u540d', 'VARCHAR(50)', nullable=False, index=True),\n Column('email', '\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9', 'VARCHAR(100)', nullable=False, index=True),\n Column('created_at', '\u4f5c\u6210\u65e5\u6642', 'TIMESTAMP', nullable=False)\n ]\n)\n\nposts_table = Table(\n name='posts',\n logical_name='\u6295\u7a3f',\n columns=[\n Column('id', '\u6295\u7a3fID', 'INT', primary_key=True, nullable=False),\n Column('user_id', '\u30e6\u30fc\u30b6\u30fcID', 'INT', nullable=False, foreign_key=True),\n Column('title', '\u30bf\u30a4\u30c8\u30eb', 'VARCHAR(200)', nullable=False),\n Column('content', '\u672c\u6587', 'TEXT', nullable=True),\n ]\n)\n\n# Add tables to diagram\ndiagram.add_table(users_table)\ndiagram.add_table(posts_table)\n\n# Add relationships with cardinality\ndiagram.add_edge('posts', 'users', LineType.STRAIGHT, Cardinality('*', '1'))\n\n# Generate SVG\ndiagram.save_svg('er_diagram.svg')\n```\n\n## API Reference\n\n### ERDiagram\n\nMain class for creating and managing ER diagrams.\n\n```python\nclass ERDiagram:\n def __init__(self, default_line_type: LineType = LineType.STRAIGHT)\n def add_table(self, table: Table, x: int = None, y: int = None) -> str\n def add_edge(self, from_node_id: str, to_node_id: str, line_type: LineType = None, cardinality: Cardinality = None)\n def save_svg(self, output: str)\n def render_svg(self) -> str\n```\n\n### Table\n\nRepresents a database table with columns.\n\n```python\n@dataclass\nclass Table:\n name: str # Physical table name\n logical_name: str # Logical table name (for display)\n columns: List[Column] # List of table columns\n```\n\n### Column\n\nRepresents a table column with properties.\n\n```python\n@dataclass\nclass Column:\n name: str # Physical column name\n logical_name: str # Logical column name (for display)\n type: str # Data type (e.g., 'VARCHAR(50)', 'INT')\n primary_key: bool = False\n nullable: bool = True\n foreign_key: bool = False\n index: bool = False\n```\n\n### LineType\n\nEnumeration for relationship line styles.\n\n```python\nclass LineType(Enum):\n STRAIGHT = \"straight\" # Direct line\n CRANK = \"crank\" # Angled line\n SPLINE = \"spline\" # Curved line\n```\n\n### Cardinality\n\nDefines relationship cardinality using IE notation.\n\n```python\n@dataclass\nclass Cardinality:\n from_side: str = \"1\" # \"1\", \"0..1\", \"1..*\", \"0..*\"\n to_side: str = \"1\" # \"1\", \"0..1\", \"1..*\", \"0..*\"\n```\n\n## Advanced Usage\n\n### Custom Table Positioning\n\n```python\n# Manually position tables\ndiagram.add_table(users_table, x=100, y=50)\ndiagram.add_table(posts_table, x=400, y=50)\n```\n\n### Multiple Relationship Types\n\n```python\n# One-to-many relationship\ndiagram.add_edge('posts', 'users', LineType.STRAIGHT, Cardinality('*', '1'))\n\n# Many-to-many through junction table\ndiagram.add_edge('post_categories', 'posts', LineType.CRANK, Cardinality('*', '1'))\ndiagram.add_edge('post_categories', 'categories', LineType.CRANK, Cardinality('*', '1'))\n```\n\n### Styling Features\n\n- **Primary Key Separation**: Primary key columns are automatically separated with a horizontal line\n- **NOT NULL Indicators**: Black squares indicate non-nullable columns\n- **Foreign Key Markers**: \"FK\" labels on foreign key columns\n- **Index Indicators**: \"IDX\" labels on indexed columns\n- **Smart Layout**: Tables with FK relationships are positioned adjacently\n\n## Requirements\n\n- Python >= 3.8\n- No external dependencies\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions welcome! Please feel free to submit a Pull Request.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python library for ER diagram visualization with SVG output",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/tamuto/in4viz",
"Issues": "https://github.com/tamuto/in4viz/issues",
"Repository": "https://github.com/tamuto/in4viz"
},
"split_keywords": [
"er-diagram",
" visualization",
" svg",
" database",
" diagram",
" entity-relationship"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ae6bb0a398bcec2843fd93d4eb24b576abdebceb72ebe24b74f112bfec030d26",
"md5": "85ef5d33231dfbd59391bfe0c7ccb354",
"sha256": "e0265b0070f6dc93fe380520dd89f563f95a4cdc9467807440b7b0e10d95adb5"
},
"downloads": -1,
"filename": "in4viz-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "85ef5d33231dfbd59391bfe0c7ccb354",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 14873,
"upload_time": "2025-08-18T07:45:50",
"upload_time_iso_8601": "2025-08-18T07:45:50.556155Z",
"url": "https://files.pythonhosted.org/packages/ae/6b/b0a398bcec2843fd93d4eb24b576abdebceb72ebe24b74f112bfec030d26/in4viz-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b66fde46b084ba116159527d41132134f6301a365c0ec07fa0b17a47b67811d5",
"md5": "e6d84b89a245dce039f6bc026ea34eff",
"sha256": "0f7fbe12b51fe7a763797e200b86d87d390ddaf328278be86d21c10696345def"
},
"downloads": -1,
"filename": "in4viz-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "e6d84b89a245dce039f6bc026ea34eff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 13833,
"upload_time": "2025-08-18T07:45:51",
"upload_time_iso_8601": "2025-08-18T07:45:51.816910Z",
"url": "https://files.pythonhosted.org/packages/b6/6f/de46b084ba116159527d41132134f6301a365c0ec07fa0b17a47b67811d5/in4viz-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-18 07:45:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tamuto",
"github_project": "in4viz",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "in4viz"
}