Skip to main content

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

Metadata

Release files for sqlalchemy-lsp 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for sqlalchemy-lsp 0.2.4
File Actions
sqlalchemy_lsp-0.2.4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for sqlalchemy_lsp-0.2.4-py3-none-win_amd64.whl
sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_x86_64.whl
sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_aarch64.whl
sqlalchemy_lsp-0.2.4-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for sqlalchemy_lsp-0.2.4-py3-none-macosx_11_0_arm64.whl
sqlalchemy_lsp-0.2.4-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for sqlalchemy_lsp-0.2.4-py3-none-macosx_10_12_x86_64.whl

Total release size: 12.2 MB

Release files / sqlalchemy_lsp-0.2.4-py3-none-win_amd64.whl

Download URL sqlalchemy_lsp-0.2.4-py3-none-win_amd64.whl
Size 2.5 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
6001327f03bd96bced0e4f5356bad983337c8558d4fc8afeadf54dadcc008c46
BLAKE2b-256 checksum
How to use checksums
3f46dd2c0d0b99be33ae2bf67b02b8ba3bd947b3c13e43a317f25bb192471d00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Release files / sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_x86_64.whl

Download URL sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
9749ab7f95d697e47008d64a7dc2cdc13c9c2bedfcfc4228287c6098c75e5f17
BLAKE2b-256 checksum
How to use checksums
887d5e825c4d7666f6984155772f0a73ce87e2ffcd8e6372d34a2e777c4e12f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Release files / sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_aarch64.whl

Download URL sqlalchemy_lsp-0.2.4-py3-none-manylinux_2_28_aarch64.whl
Size 2.4 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
26ab071c3b93a412becad3bc85719eb626c6fa46129e98c015f12805fbf8e0ff
BLAKE2b-256 checksum
How to use checksums
57fd7e62d21adbf84f4c317d9d37fec38359458f1871eaa2ef439386da0efe36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Release files / sqlalchemy_lsp-0.2.4-py3-none-macosx_11_0_arm64.whl

Download URL sqlalchemy_lsp-0.2.4-py3-none-macosx_11_0_arm64.whl
Size 2.3 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1f68c1f037f060dd5fb13ff22e99bd01be0f66f7622cf9e3f95b13082e3d2233
BLAKE2b-256 checksum
How to use checksums
2b7351acf96b31e50664360ec87a08f7801a5005582e336ed958443a7c04d0e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Release files / sqlalchemy_lsp-0.2.4-py3-none-macosx_10_12_x86_64.whl

Download URL sqlalchemy_lsp-0.2.4-py3-none-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a1c17df8489391c06e2bd70efe84fa942bf53530d1a26ee3f27de11b9a7e6148
BLAKE2b-256 checksum
How to use checksums
9581ee1f9eef41e1df2c5a0ba35117fce5a72947ea5f5673a279cac1d6aa1837
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Security for sqlalchemy-lsp 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page