A CLI tool to generate SQL project boilerplate
Project description
Genshot SQL
Created by Pranav Verma
Genshot SQL is an AI-powered Python library that allows you to interact with a MySQL database using natural language. Instead of writing SQL queries manually, you can ask questions in plain English and receive results directly from your database.
The library uses Retrieval-Augmented Generation (RAG), FAISS, and Ollama to understand your database schema and generate accurate SQL queries.
Features
- Chat with your MySQL database using natural language
- Schema-aware SQL generation
- FAISS-powered semantic schema retrieval
- Local AI inference using Ollama
- Read-only query generation (SELECT queries)
- Fast and lightweight setup
How It Works
- Provide your database schema.
- The schema is embedded and indexed using FAISS.
- Ask questions in plain English.
- The AI retrieves the most relevant schema context.
- The LLM generates SQL.
- The query is executed on MySQL.
- Results are returned to the user.
Dependencies
Install the required Python packages:
pip install faiss-cpu mysql-connector-python numpy
Ollama Requirements
Install Ollama and pull the required model:
ollama pull llama3.2:3b
You will also need an embedding model:
ollama pull nomic-embed-text
Installation
pip install genshot_sql
Example Usage
from genshot_sql import chat
chat()
Example conversation:
You: Show all employees in the IT department
SQL:
SELECT e.*
FROM employee e
INNER JOIN department d
ON e.department_id = d.id
WHERE d.name = 'IT';
Result:
...
Use Cases
- Internal business analytics
- Database exploration
- Rapid SQL prototyping
- Educational projects
- AI-powered database assistants
Tech Stack
- Python
- MySQL
- FAISS
- NumPy
- Ollama
- Llama 3.2 3B
- Retrieval-Augmented Generation (RAG)
License
MIT License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters