Skip to main content

sqlctx

sqlctx or (SQLContext) is a tool for generating LLM context from database tables. It is targeted at data practioners as a force multiplier, codifying the process of providing table schema to LLMs inside of AI-enabled code editors.

Rather than existing as an editor extension, SQLContext outputs context about your database to a directory (./sqlctx/{schema_name}/{database_name}/{table_name}.yml) on a per table basis so that you can include them with any LLM-enabled editor by mentioning the file for that database table. Alternatively, there's a combined.yml file that includes output from all the columns from all the tables for long-context LLMs.

Inside each yml file is metadata like the table, database, & schema names, as well as sample values for each column. If you have set column or table comments using tools like DBT or SQLMesh, they will also be extracted.

SQLContext pairs well with:

  • Visual Studio Code
  • Cursor
  • Zed
  • Windsurf

SQLContext supports databases that use the following protocols:

  • DuckDB
  • Postgres
  • MySQL

Getting Started

Start by installing either uv or pipx to run python CLIs without installing to system packages.

Configuration

SQLContext can be run on demand or configured. To configure for a given directory, run the following to generate a config file. You will need your database connection information handy.

uvx sqlctx add or if you're using pipx pipx sqlctx add

A config file will be written to .sqlctx/config.toml. You can embed environment variables directly in the toml like ${ENV_VAR} and they will be replaced if the variable has been set.

Generating Context

You can generate context with the uvx sqlctx generate command. It will be written to the relative directory ./sqlctx.

It is recommended that you check this directory into your repository and not gitignore, since your editor likely does not treat gitignored files the same as regular project files, and this will break the expected editor workflow.

Consuming Context

Since most AI editors allow mentioning files, SQLContext relies on this. When writing a new query, simply "mention" a table to include the schema and a few sample records in the context of your chat.

For example, if I'm writing a query calculting ARPU, I might choose to mention my sessions table and revenue table, since I know these are relevant.

  1. Visual Studio Code - CMD + / from any copilot input to include any project file
  2. Zed - CMD + / from the context pane to include any project file
  3. Cursor — @-mention the relevant tables in chat, composer, or inline edit
  4. Windsurf - @-mention the relevant table from the Cascade UI

Many editors also have a RAG-search that surfaces relevant files without explicit mention, but explicitly mentioning relevant tables tends to lead to the highest quality generations.

Metadata

Release files for sqlctx 0.1.7

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

Source distribution (sdist)

Source distribution for sqlctx 0.1.7
File Size Uploaded Provenance
sqlctx-0.1.7.tar.gz 20.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlctx 0.1.7
File Interpreter ABI Platform
sqlctx-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 41.5 kB

Release files / sqlctx-0.1.7.tar.gz

Download URL sqlctx-0.1.7.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
16156051ffa841f4c9bde5562a70cc31160bdab9d71d21f1a7442095b72f4c59
BLAKE2b-256 checksum
How to use checksums
1c4b018d58b4877b0e595b5c4793f140fc34b96f8f0e6a62e9ddb6ea96172273
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.30

Release files / sqlctx-0.1.7-py3-none-any.whl

Download URL sqlctx-0.1.7-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1ec4c98bc304c6626304ab6d077b7f17ce50ac5cee118de0f9eab275582a571
BLAKE2b-256 checksum
How to use checksums
a5ac5ca309828a7077d30a3ead216e7108ade824def3696ef5ae1b86c04b5b59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.30

Security for sqlctx 0.1.7

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