altra's profile picture
altra

database

Public

Query SQLite and Postgres from LM Studio — inspect schemas, list tables, and sample rows. Read-only by default.

174 Downloads

README

Database Plugin for LM Studio — Natural Language SQL for Local & Remote Databases

Keywords: lm studio plugin, natural language sql, local database ai, sqlite ai, postgres ai, text to sql, database explorer, no cloud, private database access

Natural language database access for LM Studio. Query SQLite and Postgres databases in plain English — inspect schemas, sample tables, run SQL, and explore your data without leaving the chat. Read-only by default; write operations opt-in.


What It Does

  • SQL queries — run SELECT statements (and optionally INSERT/UPDATE/DELETE) against SQLite or Postgres
  • Schema inspection — list tables and view column definitions
  • Data sampling — preview the first rows of any table
  • Write protection — all write operations blocked unless explicitly enabled in settings
  • Result truncation — large result sets truncated to configured row limit

Who This Is For

  • Developers who want to query local databases without switching to a separate SQL client
  • Data analysts who want natural language answers from their data without writing SQL manually
  • Anyone with a SQLite or Postgres database who wants text-to-SQL with no cloud, no data leaving the machine
  • Teams exploring unfamiliar databases who want schema discovery in plain English

Installation

cd database-plugin
npm install
npm run build

Load the built plugin folder in LM Studio.


Configuration

FieldDefaultDescription
SQLite Database Path(blank)Absolute path to a .db or .sqlite file
Postgres Connection String(blank)e.g. postgresql://user:pass@localhost:5432/mydb
Allow Write QueriesfalseEnable INSERT, UPDATE, DELETE, CREATE, DROP — modifies your database
Max Result Rows200Truncate query results to this many rows

Warning: Enable write queries only if you trust the model and the queries being run. There is no undo.


Tool: database

Single tool with four actions.

query

Run a SQL statement.

database(action="query", sql="SELECT * FROM users WHERE active = 1 LIMIT 20")
database(action="query", db_type="postgres", dsn="postgresql://...", sql="SELECT count(*) FROM orders")

Write statements (INSERT, UPDATE, DELETE, DROP, etc.) are blocked unless Allow Write Queries is enabled.

tables

List all tables in the database.

database(action="tables")
database(action="tables", db_type="postgres")

schema

Show columns, types, nullability, and primary key info for a table.

database(action="schema", table="users")

sample

Show the first 10 rows of a table.

database(action="sample", table="orders")

Shared parameters:

  • db_type — sqlite (default) or postgres
  • db_path — path to SQLite file (overrides config)
  • dsn — Postgres connection string (overrides config)
  • sql — SQL for the query action
  • table — table name for schema / sample

Example Workflows

Explore an unfamiliar database:

"What tables are in this database and what does each one look like?" → database(action="tables") then database(action="schema", table="...") per table

Answer a data question:

"How many orders were placed in the last 30 days?" → database(action="query", sql="SELECT count(*) FROM orders WHERE created_at >= date('now','-30 days')")

Sample before querying:

"Show me a few rows from the products table" → database(action="sample", table="products")

Postgres:

"Connect to my Postgres database and show the schema for the payments table" → database(action="schema", db_type="postgres", table="payments")


Security Notes

  • Write queries are blocked by default via a regex pattern matching INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, TRUNCATE, and REPLACE
  • The connection string / database path is stored in plugin config and never sent to external services
  • Results are truncated at Max Result Rows — raw database dumps are not possible unless the limit is raised

💚 Support Development

This plugin is free and open source. If you find it useful, consider supporting development:

Ko-fi
TierAmountPerks
☕ Coffee$3Name in credits
🍔 Lunch$10+ Priority support
🍕 Pizza$25+ Name in README
🏆 Founding$50+ Lifetime support, consultation

Every coffee helps keep this project alive! ☕