skillfed

WTForms-SQLAlchemy

SQLAlchemy tools for WTForms

wtforms-sqlalchemy v0.4.2 122.4K downloads/30d#11,954 on PyPI104
Permissive 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) Active released

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-sqlalchemy

uv

uv add wtforms-sqlalchemy

poetry

poetry add wtforms-sqlalchemy

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Internet :: WWW/HTTP :: WSGITopic :: Internet :: WWW/HTTP :: WSGI :: ApplicationTopic :: Software Development :: Libraries :: Application Frameworks

Tags

sqlalchemy form generationwtforms database integrationquery select fieldmodel to formsqlalchemy model forms
form-generationsqlalchemy-integration

More Application Frameworks packages