Skip to main content

Terminal-based Text-to-SQL converter with AI model integration

Project description

T2S - Text to SQL CLI

PyPI version License: MIT Python 3.8+

A powerful, privacy-first terminal-based Text-to-SQL converter that transforms natural language queries into SQL statements using state-of-the-art AI models—all running locally on your machine. Because your database deserves the best, and so does your privacy.

Created by Lakshman Turlapati

Privacy & Security First

Your data stays where it belongs—on your machine. T2S operates entirely locally, free from external APIs, delivering uncompromised privacy and security. Ideal for sensitive enterprise databases and personal projects alike.

Features

T2S is packed with capabilities to streamline your database querying experience:

Advanced AI Workflows

  • Multiple specialized AI workflows tailored to diverse use cases
  • Intelligent model selection based on your hardware and accuracy requirements
  • Automatic schema analysis and query optimization
  • Support for complex multi-table joins and aggregations

Smart Database Integration

  • Auto-detection of local databases (SQLite, PostgreSQL, MySQL)
  • Real-time schema analysis and intelligent table selection
  • Query validation and automatic error correction
  • Elegant result visualization in the terminal

Beautiful Terminal Experience

  • Rich ASCII art branding paired with an intuitive interface
  • Interactive configuration with memory compatibility warnings
  • Real-time loading animations and progress indicators
  • Syntax highlighting for SQL queries and results

Enterprise-Ready

  • Fully offline operation—no internet required post-setup
  • Local model storage and management
  • Cross-platform support (macOS, Windows, Linux)
  • Memory-aware model recommendations

AI Model Recommendations

Choosing the right AI model is key to unlocking T2S’s full potential. Here’s how to pick one that fits your needs:

For Best Results (95%+ Accuracy)

  • Gemma 3 (12B) - Ideal for production environments and complex queries
  • Defog SQLCoder (7B) - A specialized SQL model, perfect for technical users

For Most Users (80-90% Accuracy)

  • Gemma 3 (4B) - Recommended for 95% of users, striking a balance between accuracy and performance
    • Runs efficiently on most modern hardware with impressive results

For Experimentation (40-60% Accuracy)

  • SmolVLM (500M) - Ultra-lightweight and runs on any computer
    • Great for learning, testing, and resource-limited setups

T2S includes memory compatibility warnings to guide you toward the best model for your system.

Installation

Quick Start

pip install t2s-cli

For Gemma Model Support

Some models require additional dependencies:

# Option 1: Install with Gemma support
pip install t2s-cli[gemma]

# Option 2: For all features
pip install t2s-cli[all]

macOS Users (if needed)

# If SentencePiece build issues arise
brew install sentencepiece protobuf
pip install t2s-cli

Getting Started

Launch T2S

t2s

First-Time Setup (Interactive Wizard)

  1. Select an AI model based on your needs and system capabilities
  2. Connect to your databases (SQLite, PostgreSQL, MySQL)
  3. Download your chosen model (handled automatically)

Start Querying

t2s query "Show me all customers who ordered in the last month"

Usage Examples

Interactive Mode

t2s

Launches an interactive experience with model management, database configuration, and query execution.

Direct Query Mode

t2s query "Find top 5 products by revenue this year"

Configuration Management

t2s config    # Full configuration menu
t2s models    # Manage AI models
t2s databases # Manage database connections

Supported Databases

  • SQLite - Perfect for local development and small projects
  • PostgreSQL - Enterprise-grade relational database
  • MySQL - Popular choice for web applications

More database support on the way!

Real-World Examples

Basic Queries

Input: "Show me all active users" Output:

SELECT * FROM users WHERE status = 'active';

Input: "Count orders by month" Output:

SELECT DATE_FORMAT(created_at, '%Y-%m') as month, COUNT(*)
FROM orders GROUP BY month ORDER BY month;

Complex Queries

Input: "Find customers who spent more than $1000 last quarter" Output:

SELECT c.name, c.email, SUM(o.total) as total_spent
FROM customers c
JOIN orders o ON c.id = o.customer_id
WHERE o.created_at >= DATE_SUB(NOW(), INTERVAL 3 MONTH)
GROUP BY c.id, c.name, c.email
HAVING total_spent > 1000
ORDER BY total_spent DESC;

Who Is This For?

T2S caters to a broad audience:

  • Database Administrators - Swiftly explore and analyze database contents
  • Developers - Prototype and query databases during development
  • Data Analysts - Turn business questions into SQL without syntax struggles
  • Students & Researchers - Learn SQL and experiment with AI models locally
  • Privacy-Conscious Users - Handle sensitive data without external exposure

Development & Contributing

Contributions are welcome! This project reflects significant effort and meticulous care.

Setup Development Environment

git clone [https://github.com/lakshmanturlapati/t2s-cli.git](https://github.com/lakshmanturlapati/t2s-cli.git)
cd t2s-cli
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e ".[dev]"

Run Tests

pytest

Code Quality

black .
flake8 .

Roadmap

  • Support for additional databases (Oracle, SQL Server)
  • Natural language explanations for results
  • Query history and favorites
  • Custom model fine-tuning
  • Integration with popular BI tools

License

This project is licensed under the MIT License—see the LICENSE file for details.

Acknowledgments

Developed with support and guidance from the University of Texas at Dallas.

Special Thanks:

  • Professor Srikanth Kannan - For invaluable guidance and inspiration
  • The open-source community for essential libraries
  • HuggingFace for model infrastructure
  • Contributors and users who help refine T2S

Author

Lakshman Turlapati

"Bringing the power of AI to your database, locally and securely."

This README will evolve with the project. Your feedback and contributions are always appreciated!

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

t2s_cli-0.2.1.tar.gz (62.7 kB view details)

Uploaded Source

Built Distribution

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

t2s_cli-0.2.1-py3-none-any.whl (62.0 kB view details)

Uploaded Python 3

File details

Details for the file t2s_cli-0.2.1.tar.gz.

File metadata

  • Download URL: t2s_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 62.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for t2s_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ee91290525141c7525f17f6e0d98a3cdfa9856c606df0056ab44ce7a51972ea9
MD5 6a5fedd1f0cf470e3e15b1dd412bb681
BLAKE2b-256 7e2a1dcb71e27499a661b3019b0e98586c257873ad3e844f6fb9a7358ff76dd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for t2s_cli-0.2.1.tar.gz:

Publisher: release.yml on LakshmanTurlapati/t2s-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file t2s_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: t2s_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 62.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for t2s_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 afb05166627a45e7589d27fd52fa4da4277041299d6354b8042843b335ebc4c6
MD5 6818513d3a46e34f7e9eb577699df3a8
BLAKE2b-256 c76a2860d9595af78ea481ec837cd77fd4e9959ab21735741948407b19574422

See more details on using hashes here.

Provenance

The following attestation bundles were made for t2s_cli-0.2.1-py3-none-any.whl:

Publisher: release.yml on LakshmanTurlapati/t2s-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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