Skip to main content

A tool for generating LLM context from database tables

Project description

sqlctx

sqlctx or (SQLContext) is a tool for generating LLM context from database tables. It is targeted at data professionals 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) such that you can include them with any LLM-enabled editor by mentioning the file for that database table.

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

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.

Project details


Download files

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

Source Distribution

sqlctx-0.1.2.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

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

sqlctx-0.1.2-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file sqlctx-0.1.2.tar.gz.

File metadata

  • Download URL: sqlctx-0.1.2.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for sqlctx-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3a9b867ce3498143f6260d344cb76d2d54df889c22bbde3dee8e32f5c9bbb8bc
MD5 0462beb934b3bed988fd12e749cba971
BLAKE2b-256 8ee2ad30e11a02306b3af8a8c5281951f81ba589b73c87d544ffbbc33a0ceb76

See more details on using hashes here.

File details

Details for the file sqlctx-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sqlctx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for sqlctx-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c8239a7750326731414457afd3f531c4ba636c2ac7c197271dcaa3aec4e13812
MD5 019de4eed6d396b52300d8a14ea10b0d
BLAKE2b-256 a6e88927e9fd949e55efd46d17ed9537a969fd84498bf3510cdf7538b891ac8c

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