Skip to content

MajorAbdullah/sql-ai-api-main

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 

Repository files navigation

SQL AI API

Overview

This project provides an API that leverages AI to interact with a SQL database. It allows users to perform database operations using natural language queries, which are translated into SQL by an AI model.

Purpose and Problem Solved

The primary purpose of this project is to simplify database interactions for users who may not be proficient in SQL. It bridges the gap between natural language and structured query language, enabling more intuitive data access and manipulation.

Key Features

  • Natural Language to SQL: Translates user queries in plain English into executable SQL commands.
  • FastAPI Backend: Built with FastAPI for high performance and ease of development.
  • OpenAI Integration: Utilizes OpenAI's powerful language models for translation.
  • PostgreSQL Support: Connects to a PostgreSQL database for data storage and retrieval.
  • Asynchronous Operations: Leverages async capabilities for efficient handling of requests.

Requirements

  • Python 3.8+
  • pip (Python package installer)
  • PostgreSQL Database (local or cloud-hosted)
  • OpenAI API Key

Python Packages:

fastapi
uvicorn[standard]
openai
databases[postgresql]
sqlalchemy
psycopg2-binary
python-dotenv

File Structure

(A brief overview of the project's directory structure can be added here once finalized)

sql-ai-api-main/
β”œβ”€β”€ .env          # Environment variables (OPENAI_API_KEY, DATABASE_URL)
β”œβ”€β”€ requirements.txt # Project dependencies
β”œβ”€β”€ setup.md        # Detailed setup instructions
β”œβ”€β”€ tutorial_full.py # Example FastAPI application
└── README.md       # This file

Getting Started

  1. Clone the Repository:

    git clone <your-repo-url>
    cd sql-ai-api-main
  2. Set up a Virtual Environment (Recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Configure Environment Variables: Create a .env file in the project root and add your credentials:

    OPENAI_API_KEY=your_openai_api_key
    DATABASE_URL=postgresql://user:password@host:port/database_name

    Remember to add .env to your .gitignore file.

  5. Run the Application: (Refer to setup.md or specific run instructions for the main application file, e.g., tutorial_full.py)

    uvicorn tutorial_full:app --reload 

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues to improve the project.

(Add specific contribution guidelines if applicable)

License

(Specify the project's license here, e.g., MIT, Apache 2.0. If no license is chosen, state that.)

This project is currently unlicensed.

Contact

Syed Abdullah Shah

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages