Skip to main content

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

  1. Provide your database schema.
  2. The schema is embedded and indexed using FAISS.
  3. Ask questions in plain English.
  4. The AI retrieves the most relevant schema context.
  5. The LLM generates SQL.
  6. The query is executed on MySQL.
  7. 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

  1. Install the library.

  2. Install all the dependencies.

  3. Install Ollama and pull the llama3.2:3b model.

  4. Insert your database configuration and schema in config.py.

  5. 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)

Source distribution for genshot-sql-pranav 0.1.4
File Size Uploaded
genshot_sql_pranav-0.1.4.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for genshot-sql-pranav 0.1.4
File Interpreter ABI Platform
genshot_sql_pranav-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / genshot_sql_pranav-0.1.4.tar.gz

Download URL genshot_sql_pranav-0.1.4.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0b156ca96790fd14a003235c0831b076313410f07f46278b273855fa0a7fc61b
BLAKE2b-256 checksum
How to use checksums
708dc26603b4e3f329c0a91b5b62319b0b918b464a6431c1f20ef77127424043
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / genshot_sql_pranav-0.1.4-py3-none-any.whl

Download URL genshot_sql_pranav-0.1.4-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d446d42afcc0f6592c477a94bed3e495a7364d7d05a7261d054f5fd2c099849
BLAKE2b-256 checksum
How to use checksums
0940144e8f2808369648ada2605a6332335f4e816ad626288e44dedf1fb2c6b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page