Skip to main content

Natural Language to SQL CLI powered by a fine-tuned LLM.

Project description

Transqlate

Transqlate is a production‑ready natural language → SQL assistant powered by a fine‑tuned Phi‑4 Mini model. It lets anyone—technical or not—create and run complex queries over SQLite, PostgreSQL, MySQL, MSSQL, or Oracle databases using plain English.


Key Features

  • Schema‑Aware NL→SQL – Automatically extracts your database schema and prunes it with an RAG pipeline so prompts fit within model limits.
  • Interactive CLI – Generate queries, explore schemas, edit or write SQL, and dynamically switch connections with :changedb (alias :change_db).
  • Safe Execution – DDL/DML statements require explicit confirmation. Lost connections trigger an optional reconnect with troubleshooting tips.
  • Chain‑of‑Thought Reasoning – View the model’s reasoning and final SQL, converted from SQLite syntax to your database dialect with automatic schema qualification.
  • Customizable Inference – Control maximum generation length (--max-new-tokens), enable Python tracebacks for debugging, and point to local or HF-hosted model weights.
  • Offline‑Friendly – Runs on CPU and can pre‑download the sentence‑transformer embedding model so future runs work without internet access.
  • Supports One‑Shot Queries – Use -q "question" for quick, non‑interactive SQL generation.

Installation

pip install transqlate

Usage

Launch the interactive CLI:

transqlate --interactive

Run a single question:

transqlate -q "List all customers who made purchases in March." --db-path path/to/database.db

REPL commands include :show schema, :history, :edit, :write, :examples, :clear, :changedb, :about, and :exit.


License

MIT License


Author

Shaurya Sethi Contact: shauryaswapansethi@gmail.com


For the full user manual and source code, visit the GitHub repository or the Hugging Face model page.


What's New in v0.1.2

  • Cross-dialect SQL post-processing: Automatically transforms model-generated (SQLite-style) SQL into the target dialect (PostgreSQL, MySQL, MSSQL, Oracle) with clear conversion notices.
  • Enhanced CLI workflow: Added :edit for modifying generated SQL, :write for manual queries, and seamless database switching with :changedb/:change_db.
  • Improved schema extraction: Robust support for PostgreSQL, Oracle, and MSSQL with qualified and escaped identifiers; Oracle system tables can now be filtered.
  • Safer execution and state management: CLI now detects and recovers from lost connections, rolls back on errors, and requires confirmation for DDL/DML.
  • History and troubleshooting: Query history now shows manual/edited status and execution results. Added :troubleshoot for step-by-step connection help.
  • Token limit control: Set output length using the --max-new-tokens argument (default: 2048).
  • Numerous bugfixes and UX refinements: Identifier quoting, error messages, startup feedback, and more.

For the full release notes, see CHANGELOG.md.

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

transqlate-0.1.2.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

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

transqlate-0.1.2-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transqlate-0.1.2.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for transqlate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5d4ee005fdf22dff2ac22ad65fa9f4c40464216d18b0a2dd5d1b64c4a4749f80
MD5 6d5ede61902a2daf77103a1842f94fb6
BLAKE2b-256 670a1fd09538e07ff238d47bbcf483ffe1863d9eb845e607d7018dadded8847a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: transqlate-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for transqlate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7328ae20c703e33e44c742dd31cbfd15aaf501f572ba72d854773c728feaef64
MD5 9420e6a818103579a9c18291373bf8fb
BLAKE2b-256 f8da18a9688e5bcd9d061ec238140ebccd9c47387cc3c9f1a0e5ba2930f7b2fe

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