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 the bundled extension:

just install-zed

Then 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.1.5-py3-none-win_amd64.whl (2.3 MB view details)

Uploaded Python 3Windows x86-64

sqlalchemy_lsp-0.1.5-py3-none-manylinux_2_28_x86_64.whl (2.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

sqlalchemy_lsp-0.1.5-py3-none-manylinux_2_28_aarch64.whl (2.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

sqlalchemy_lsp-0.1.5-py3-none-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

sqlalchemy_lsp-0.1.5-py3-none-macosx_10_12_x86_64.whl (2.3 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: sqlalchemy_lsp-0.1.5-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.1.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8e92add75f2c1eb77323f642107dd6731dd5cde7d8fa38286f48da0f1bd5a1e3
MD5 9f3c3d46c0c158c6c1d7f6efd148aaa8
BLAKE2b-256 de14bc85ab67d308d5d8a51665cb67b33186537939bed698d9302ef3b47bfa64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlalchemy_lsp-0.1.5-py3-none-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.1.5-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a55d38ad23a53482c968296473468ea41405f6fb3e62c0ab7e6516be3e3ad96a
MD5 9cf760818f2ab0000c01692f74541282
BLAKE2b-256 7435e0cc8282bca02f2d74ab5de7afb90f6059c778e7737c4824023601f98cf2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlalchemy_lsp-0.1.5-py3-none-manylinux_2_28_aarch64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3, manylinux: glibc 2.28+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.1.5-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ca84cc816a4ca72f1c4e34d5dd2ff204f983d2cfbd393ed6dc08b2d34aca0946
MD5 a19ab006d49faaa08e717e1376657a14
BLAKE2b-256 f327d6c6d573f4b5de69ee7cd66c97d09b8cb677e4827cd9b5e2ade726f8de2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlalchemy_lsp-0.1.5-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.1.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a534f661214eecd4158fbbba59d21fbec5a765e8dba5a85a2ab05f4f456989cf
MD5 3062438fd4e3819767c5869c5c771db2
BLAKE2b-256 a5d8fd655112738a9f07a7087145280e9c60fc82b49c9d536e2ff7e55b7137d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlalchemy_lsp-0.1.5-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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.1.5-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dcbe8c3759c698bf978be51f173bb62ac3d81a70b2a05932ceef71c1baba8071
MD5 d4c46cae175dfaf8d7dcb50fec211acf
BLAKE2b-256 65892863ff5437422c70c34359b33526578721a8e6c0ae99c15a132f52cd06d7

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