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.
Installation
pip install genshot-sql-pranav
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
Quick Start
-
Install the library.
-
Install all the dependencies.
-
Install Ollama and pull the
llama3.2:3bmodel. -
Insert your database configuration and schema in
config.py. -
Run
chat_with_database.py.
python chat_with_database.py
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
Release files for genshot-sql-pranav 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| genshot_sql_pranav-0.1.4.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| genshot_sql_pranav-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.6 kB