Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemy_lsp-0.2.0-py3-none-win_amd64.whl (2.5 MB view details)

Uploaded Python 3Windows x86-64

sqlalchemy_lsp-0.2.0-py3-none-manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

sqlalchemy_lsp-0.2.0-py3-none-manylinux_2_28_aarch64.whl (2.4 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

sqlalchemy_lsp-0.2.0-py3-none-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

sqlalchemy_lsp-0.2.0-py3-none-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file sqlalchemy_lsp-0.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: sqlalchemy_lsp-0.2.0-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

Hashes for sqlalchemy_lsp-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9d0197c6fb135942a22ae748bf349082d802fca60eed7f5b450f51b8fde683e2
MD5 10547b80dbefe194a0f9e29fec88738a
BLAKE2b-256 66acef04b0f0473f621f950a48b21de20e98b9e2fc7b20eb7541c94d624d8629

See more details on using hashes here.

File details

Details for the file sqlalchemy_lsp-0.2.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: sqlalchemy_lsp-0.2.0-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

Hashes for sqlalchemy_lsp-0.2.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a8fa1adc91ad234726008e5cb9976bdcd24fa27b5860460c46f2509a773d5330
MD5 7d5afbc09f6d80e39d5b7daf69068ee8
BLAKE2b-256 d687b3de5a4392c2d3f2fe3313a7b7a0f255d912d3a2982ffbe62256df360a2b

See more details on using hashes here.

File details

Details for the file sqlalchemy_lsp-0.2.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

  • Download URL: sqlalchemy_lsp-0.2.0-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

Hashes for sqlalchemy_lsp-0.2.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a8543c29ccef38629d71b677b0a509a734ae45479c6a48e1cbd52266801d2763
MD5 b60c1f80a5652ac2abb414d56aae53ee
BLAKE2b-256 1abad55b48b4b2784b61c8ffb7afc7c82d67a451c1cd3392a00120cdf8166c6f

See more details on using hashes here.

File details

Details for the file sqlalchemy_lsp-0.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: sqlalchemy_lsp-0.2.0-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

Hashes for sqlalchemy_lsp-0.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 052b7cde70fd07475667abb11f246791be62f7278bb23a5c5a14ad29291d48d4
MD5 d32906fdd92c86d2b672f9e561440153
BLAKE2b-256 ac769bc757508427bf9eb52ffbf1d44a173f9605da92922c1152f92e45ab7b86

See more details on using hashes here.

File details

Details for the file sqlalchemy_lsp-0.2.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: sqlalchemy_lsp-0.2.0-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

Hashes for sqlalchemy_lsp-0.2.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ce25a07d0f26583493b818edf7ff63ee45e6f8f77b65469866c956acb0f0aa41
MD5 6a206f55168989337f2602d6ed9f7678
BLAKE2b-256 ac726903621fdbc6892b772e65fc7b01e99d0fb760d49c0b59c3829bfff7be60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page