WTForms-SQLAlchemy
SQLAlchemy tools for WTForms
What it is and what it does
WTForms-SQLAlchemy bridges WTForms and SQLAlchemy by providing form generation and database-aware form fields. It was forked from WTForms' deprecated sqlalchemy extension to maintain independent development and release cycles. The package offers two main features: automatic form generation from SQLAlchemy models via model_form(), and specialized form fields (QuerySelectField, QuerySelectMultipleField) that populate dropdown lists directly from database queries.
The package is designed for web applications that need to build forms tied to database models without manually defining each field. It's commonly used in Flask applications where forms need to display related records as choices. With low install friction and active maintenance, it integrates cleanly into projects already using both WTForms and SQLAlchemy.
Use it for:
- Auto-generate form classes from SQLAlchemy ORM models to reduce boilerplate in CRUD interfaces.
- Populate dropdown fields with live database queries (e.g., user lists, category selections) using QuerySelectField.
- Build multi-select form fields backed by database relationships without writing custom query logic.
- Simplify form validation and data binding when working with SQLAlchemy model instances.
- Create admin interfaces or data entry forms that stay synchronized with model schema changes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates WTForms forms from SQLAlchemy models and provides form fields for selecting from database queries.
Yes. Low install friction, active maintenance, permissive BSD license, and no known vulnerabilities make this a safe choice. Install it if you're building WTForms-based applications with SQLAlchemy models and want to avoid manual form field definition or need database-backed select fields.
Install
wtforms-sqlalchemy on PyPI
pip
pip install wtforms-sqlalchemyuv
uv add wtforms-sqlalchemypoetry
poetry add wtforms-sqlalchemyInstalling WTForms-SQLAlchemy
Before you install
Low install friction with just two runtime dependencies (sqlalchemy and wtforms). Actively maintained as of 2026-04-23 with stable production status.
License in practice
BSD license (permissive) — you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install WTForms-SQLAlchemy
from wtforms_sqlalchemy.orm import model_form
from wtforms_sqlalchemy.fields import QuerySelectField
# Generate a form class from a SQLAlchemy model
MyForm = model_form(MyModel)
# Or use QuerySelectField for database-backed dropdowns
class MyForm(Form):
user = QuerySelectField(query_factory=lambda: User.query)
Requires Python 3.9 or later; sqlalchemy and wtforms must be installed.
Verify before relying
- Whether QuerySelectField and QuerySelectMultipleField support async SQLAlchemy sessions or only synchronous queries.
- Compatibility with the latest major versions of sqlalchemy (2.0+) and wtforms (3.x).
- Whether model_form supports all SQLAlchemy column types or has known limitations.
Package facts
| License | Copyright (c) 2020 by Thomas Johansson, James Crasta and others. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — sqlalchemy, wtforms |
| Maintenance | actively maintained — 658 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 122,365/month — #11,954 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: wtforms_sqlalchemy-0.4.2-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
WTForms-AlchemyAutomatically generates WTForms form classes…
permissive · top 15,000 on PyPI
WTFormsWTForms provides form validation, rendering,…
permissive · top 5,000 on PyPI
WTForms-ComponentsExtends WTForms with additional field types,…
permissive · top 15,000 on PyPI
flask-mongoengineFlask-MongoEngine integrates MongoEngine…
permissive · top 15,000 on PyPI
Flask-SQLAlchemyFlask-SQLAlchemy integrates SQLAlchemy database…
permissive · top 1,000 on PyPI
sqladminGenerates a web-based admin interface for…
permissive · top 5,000 on PyPI
Flask-WTFFlask-WTF integrates WTForms with Flask to…
permissive · top 5,000 on PyPI
Bootstrap-FlaskBootstrap-Flask provides Jinja macros that…
permissive · top 15,000 on PyPI
sqlbagsqlbag provides a collection of SQLAlchemy…
unclear · top 15,000 on PyPI
WTForms-JSONAdds JSON parsing and validation support to…
permissive · top 15,000 on PyPI