sqlacodegen
Automatic model code generator for SQLAlchemy
Decision gist · record as of 2026-08-14
Yes. This is a mature, actively maintained tool (Production/Stable status, recent release) with low install friction and no known vulnerabilities. It solves a real problem—avoiding tedious hand-written ORM boilerplate—and is well-suited for projects with existing databases or frequent schema changes. The permissive MIT license adds no restrictions.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; database URL must be valid for SQLAlchemy's create_engine().
- Low friction install with only two runtime dependencies (SQLAlchemy and inflect).
- Actively maintained with a recent release and 2364 repository stars; supports Python 3.10 through 3.14.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
last release 2026-06-19 (56 days) · last repo commit 2026-07-06 · 2,364 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,842,566 downloads/mo, #3,495 on PyPI
Alternatives
Verify before relying
pip install sqlacodegen
sqlacodegen postgresql:///some_local_db
sqlacodegen --generator dataclasses sqlite:///database.db- Whether the generated code requires manual refinement for complex schemas or edge cases.
- Performance characteristics when processing very large database schemas.
What it is and what it does
sqlacodegen is a command-line tool that introspects an existing database and generates the corresponding SQLAlchemy model definitions. It reads the database schema—tables, columns, constraints, relationships—and outputs Python code that you can use directly in your application. The tool supports multiple code generation styles: traditional declarative classes, dataclasses, and SQLModel, letting you choose the pattern that fits your project.
The generator handles relationship detection (many-to-one, one-to-one, many-to-many), joined table inheritance, and produces PEP 8 compliant code. It includes options to control naming (using the inflect library to singularize class names), constraint handling, and dialect-specific type preservation. This is useful when you have an existing database and want to avoid hand-writing boilerplate ORM models, or when you need to keep models synchronized with schema changes.
Use it for
- Quickly bootstrap SQLAlchemy models from a legacy database without manual class definition.
- Generate dataclass-based models for modern Python projects that prefer immutability or type hints.
- Create SQLModel definitions for FastAPI applications that need both ORM and API schema in one model.
- Reverse-engineer relationship logic (foreign keys, many-to-many joins) automatically instead of writing it by hand.
- Maintain model code when the database schema changes by regenerating and comparing the output.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This is a mature, actively maintained tool (Production/Stable status, recent release) with low install friction and no known vulnerabilities. It solves a real problem—avoiding tedious hand-written ORM boilerplate—and is well-suited for projects with existing databases or frequent schema changes. The permissive MIT license adds no restrictions.
Install
sqlacodegen on PyPI
Before you install
Low friction install with only two runtime dependencies (SQLAlchemy and inflect). Actively maintained with a recent release and 2364 repository stars; supports Python 3.10 through 3.14.
Requires Python 3.10 or later; database URL must be valid for SQLAlchemy's create_engine().
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install sqlacodegen
sqlacodegen postgresql:///some_local_db
sqlacodegen --generator dataclasses sqlite:///database.db
Verify before relying
- Whether the generated code requires manual refinement for complex schemas or edge cases.
- Performance characteristics when processing very large database schemas.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesSQLAlchemyinflect |
| Maintenance | Actively maintained 56 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,842,566 / month, #3,495 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: DatabaseTopic :: Software Development :: Code Generators |
Evidence: sqlacodegen-4.0.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “sqlalchemy model code generator”
- sqlacodegenReads an existing database schema and generates SQLAlchemy model code…
- paracelsusParacelsus generates Entity Relationship Diagrams from SQLAlchemy…
- sqladminGenerates a web-based admin interface for SQLAlchemy models,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also sqlalchemy-schemadisplay · SQLAlchemy · SQLAlchemy-Continuum · paracelsus · sqlalchemy-repr · app-model · sqlmodel · graphene-sqlalchemy · eralchemy · access-parser