Draw SQLAlchemy Database
Visual database designer inside VSCode — draw tables, define fields & relationships, then generate SQLAlchemy models instantly.

Features
| Feature |
Status |
| Infinite canvas with zoom & pan |
✅ |
| Drag-and-drop table nodes |
✅ |
| Inline field editing with type selector |
✅ |
| Visual relationship drawing |
✅ |
.sqlmap JSON schema format |
✅ |
Generate models.py (SQLAlchemy ORM) |
✅ |
| Export SQL DDL |
✅ |
Import SQLite .db / .sqlite3 / .sql3 |
✅ |
Import SQL dump .sql |
✅ |
| Schema validation |
✅ |
| Right-click context menus |
✅ |
| All SQLAlchemy column types |
✅ |
| Relationships (1:1, 1:N, N:M) |
✅ |
| Foreign keys, backref, cascade |
✅ |
| Association tables |
✅ |
| Composite PKs & check constraints |
✅ |
| SQLite / PostgreSQL / MySQL dialects |
✅ |
Quick Start
- Install the extension from the VSCode marketplace
- Create a project:
Ctrl+Shift+P → DrawSQL: Create New SQLMap Project
- The visual designer opens automatically
- Add tables with the
+ Table button
- Add fields inline on each table card
- Draw relationships by clicking
↔ Relation then clicking source → target
- Save with
Ctrl+S
- Generate
models.py with the Generate models.py button
{
"version": "1.0",
"database": { "dialect": "sqlite" },
"tables": [
{
"name": "user",
"fields": [
{ "name": "id", "type": "Integer", "primary_key": true, "autoincrement": true },
{ "name": "username", "type": "String", "length": 100, "unique": true, "nullable": false }
],
"relationships": [
{ "name": "posts", "type": "one_to_many", "target": "post", "backref": "owner" }
]
}
]
}
Supported SQLAlchemy Types
Integer · BigInteger · SmallInteger · String · Text · Unicode · UnicodeText · Boolean · Date · DateTime · Time · Float · Numeric · LargeBinary · JSON · JSONB · UUID · Enum · ARRAY · Interval
Commands
| Command |
Description |
DrawSQL: Open Visual Designer |
Open .sqlmap in the canvas editor |
DrawSQL: Create New SQLMap Project |
Create a new blank schema |
DrawSQL: Generate SQLAlchemy models.py |
Generate Python ORM models |
DrawSQL: Export SQL DDL |
Generate SQL CREATE TABLE statements |
DrawSQL: Import Database → SQLMap |
Import .db, .sqlite3, .sql |
DrawSQL: Validate SQLMap Schema |
Check schema for errors |
On .sqlmap files:
- Open Visual Designer
- Generate models.py
- Export SQL
- Validate schema
On .db / .sqlite3 / .sql3 / .sql files:
- Import to SQLMap
- Open diagram
Generated Output Example
from datetime import datetime
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Text
from sqlalchemy.orm import relationship, backref, DeclarativeBase
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "user"
id = Column(Integer, primary_key=True, autoincrement=True, nullable=False)
username = Column(String(100), unique=True, nullable=False, index=True)
email = Column(String(255), unique=True, nullable=False)
created_at = Column(DateTime, default=datetime.utcnow)
class Post(Base):
__tablename__ = "post"
id = Column(Integer, primary_key=True, autoincrement=True, nullable=False)
title = Column(String(500), nullable=False)
content = Column(Text)
owner_id = Column(Integer, ForeignKey("user.id"), nullable=False)
owner = relationship("User", backref=backref("posts", cascade="all, delete"))
Keyboard Shortcuts
| Key |
Action |
Ctrl+S |
Save schema |
Escape |
Deselect / cancel relation mode |
+ / - |
Zoom in / out |
Ctrl+0 |
Reset zoom |
| Scroll wheel |
Zoom |
| Middle drag |
Pan canvas |
# Generate models.py from .sqlmap
python3 core/sqlalchemy_generator.py example/blog.sqlmap models.py
# Import SQLite database
python3 core/db_importer.py mydb.db schema.sqlmap
# Parse SQL dump
python3 core/sql_parser.py dump.sql
Developer
akhmedcodes
License
MIT © akhmedcodes