Language server for SQLAlchemy ORM intelligence
Project description
sqlalchemy-lsp
Language server for SQLAlchemy ORM and Alembic. Diagnostics, completions, hover, navigation, and a headless CLI linter — one Rust binary, any LSP-capable editor.
Features
| Diagnostics | missing tablename, duplicate tablename/column, unknown FK table/column, FK type mismatch, relationship wiring errors, back_populates mismatch, uselist mismatch, orphan cascades, circular relationships, Alembic migration checks |
| Completions | FK strings, relationship() kwargs and values, mapped_column() kwargs, __table_args__ column names, model-constructor keywords, Alembic op.* names and arguments, snippets |
| Hover | model card, column card (type, nullability, FK target, indexes), FK resolution, relationship card, cascade tokens, back_populates counterpart |
| Navigation | go-to-definition, find references, rename — models, columns, relationships, FK targets |
| Signature help | model constructors, relationship() kwargs |
| Symbols | models and Alembic revisions in the symbol picker |
| Inlay hints | resolved FK targets inline |
| Code actions | generate __tablename__, fix back_populates, add missing FK column |
| Schema view | ER diagram of the workspace models |
check CLI |
same diagnostics as the LSP — sqlalchemy-lsp check . |
Diagnostics
| Code | Severity | What it catches |
|---|---|---|
SQLA-W101 |
warning | missing __tablename__ |
SQLA-E102 |
error | duplicate __tablename__ |
SQLA-E103 |
error | duplicate column name |
SQLA-E105 |
error | __table_args__ references unknown column |
SQLA-W201 |
warning | nullable=True column typed as non-optional |
SQLA-E301 |
error | FK references unknown table |
SQLA-E302 |
error | FK references unknown column |
SQLA-W303 |
warning | FK type mismatch |
SQLA-E401 |
error | relationship target not found |
SQLA-W402 |
warning | back_populates points at wrong attribute |
SQLA-W403 |
warning | back_populates target not found |
SQLA-W404 |
warning | uselist disagrees with cardinality |
SQLA-W405 |
warning | relationship target mismatch |
SQLA-H406 |
hint | missing FK for relationship |
SQLA-H407 |
hint | one-to-one missing unique=True |
SQLA-W408 |
warning | unknown cascade token |
SQLA-W409 |
warning | orphan cascade without delete |
SQLA-H410 |
hint | circular relationship |
Best-practice lints (SQLA-W1xx–SQLA-H4xx) default on and cover modernization, nullable hygiene, and Alembic migration checks.
Installation
uv tool install sqlalchemy-lsp
Or with pip:
pip install sqlalchemy-lsp
Or download a pre-built binary from the releases page.
Configuration
Zero config for standard projects. Place a sqlalchemy-lsp.toml or [tool.sqlalchemy-lsp] section in pyproject.toml at the project root.
# sqlalchemy-lsp.toml
# Path to the declarative base (auto-detected if absent)
# base = "app/database.py"
# Extra source roots for import resolution
# source_roots = ["src"]
[diagnostics]
# Run only these codes
# select = ["SQLA-E301", "SQLA-E401"]
# Suppress codes
ignore = ["SQLA-H406"]
# Override severity per code
[diagnostics.severity]
"SQLA-W303" = "error"
Suppress a single line with # noqa or # noqa: SQLA-W303.
CLI
# Run diagnostics
sqlalchemy-lsp check .
sqlalchemy-lsp check app/models/ --select SQLA-E3xx --ignore SQLA-H406
sqlalchemy-lsp check --format json
# Print the workspace ER schema
sqlalchemy-lsp schema
# Print model statistics
sqlalchemy-lsp stats
Editor Setup
Zed
Install from the Zed extensions panel (Cmd+Shift+X) — search for sqlalchemy-lsp and click Install. It activates automatically for Python files.
To control server order alongside other language servers, add to ~/.config/zed/settings.json:
{
"languages": {
"Python": { "language_servers": ["sqlalchemy-lsp", "..."] }
}
}
Helix
Merge editors/helix/languages.toml into ~/.config/helix/languages.toml.
Neovim
Requires Neovim 0.11+. Use the snippet from editors/neovim/sqlalchemy_lsp.lua or add to your init.lua:
vim.lsp.config('sqlalchemy_lsp', {
cmd = { 'sqlalchemy-lsp', 'lsp', '--stdio' },
filetypes = { 'python' },
root_markers = { 'pyproject.toml', 'sqlalchemy-lsp.toml', 'alembic.ini', '.git' },
})
vim.lsp.enable('sqlalchemy_lsp')
Other editors
The server speaks standard LSP over stdio:
sqlalchemy-lsp lsp --stdio
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlalchemy_lsp-0.2.1-py3-none-win_amd64.whl.
File metadata
- Download URL: sqlalchemy_lsp-0.2.1-py3-none-win_amd64.whl
- Upload date:
- Size: 2.5 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba62571576777649f595fe748212999a0d0c7416c9b1baef9de85fff7c8afa93
|
|
| MD5 |
a501cb54e6a7b3c11a4373514fc55155
|
|
| BLAKE2b-256 |
05dd6f6ce404e965431e62d2b6c949c4ac5f86e563fc190b8846c1f2d2af6e04
|
File details
Details for the file sqlalchemy_lsp-0.2.1-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: sqlalchemy_lsp-0.2.1-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa5e4295e3edfdeceb063665bcacf7ed0d2e9c415d20e21c3a90510d2dbaa45e
|
|
| MD5 |
1e9c131097474bc31c4b2e8d4e5eb4fd
|
|
| BLAKE2b-256 |
35ad9dc12882b0582b828e732fe7684a3a6f656cb9d1dd063f9cc2e662386c18
|
File details
Details for the file sqlalchemy_lsp-0.2.1-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: sqlalchemy_lsp-0.2.1-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 2.4 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32339f92449bda3e7e9c1c5ba2d8fd21baa76fbbf2d3e756cb1012b06a8f9a0f
|
|
| MD5 |
b217db489735f7d9b86b269e0fe5dbbf
|
|
| BLAKE2b-256 |
4a5974d3bfd7650cfb306ca18b69c09dcce6d12bea1db3d615f04a5bc8d26c8c
|
File details
Details for the file sqlalchemy_lsp-0.2.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: sqlalchemy_lsp-0.2.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d52a29367a5f90b3e7c6418566c5a927635ad5e5e3b95648c79df0c25237e89
|
|
| MD5 |
550074b9abbcb5f0ce6083adf1df86a0
|
|
| BLAKE2b-256 |
7fd0290dd31b991b0de10b76c66233163bab23505d80fb451acce35ed55563c8
|
File details
Details for the file sqlalchemy_lsp-0.2.1-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: sqlalchemy_lsp-0.2.1-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3483f2990643d8ecedd6ce987f727aa7af322e200f6717f75dd3c99d6399929d
|
|
| MD5 |
cd1693f7fcf68d806d2356617152a84a
|
|
| BLAKE2b-256 |
238c7b2ca8804182c055cfb19e1a21799ec7125495ef30f55c66b91c3376a29d
|