Skip to main content

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

  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

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

genshot_sql_pranav-0.1.4.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

genshot_sql_pranav-0.1.4-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file genshot_sql_pranav-0.1.4.tar.gz.

File metadata

  • Download URL: genshot_sql_pranav-0.1.4.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for genshot_sql_pranav-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0b156ca96790fd14a003235c0831b076313410f07f46278b273855fa0a7fc61b
MD5 6fd5b0b36d4638caa72ff8876c3801d0
BLAKE2b-256 708dc26603b4e3f329c0a91b5b62319b0b918b464a6431c1f20ef77127424043

See more details on using hashes here.

File details

Details for the file genshot_sql_pranav-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for genshot_sql_pranav-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8d446d42afcc0f6592c477a94bed3e495a7364d7d05a7261d054f5fd2c099849
MD5 c5fed0db39a29ebd8433faabfc11592f
BLAKE2b-256 0940144e8f2808369648ada2605a6332335f4e816ad626288e44dedf1fb2c6b4

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