{"id":20944897,"url":"https://github.com/liamca/azure_openai_nl2sql","last_synced_at":"2026-03-19T18:09:05.545Z","repository":{"id":252420236,"uuid":"840379735","full_name":"liamca/azure_openai_nl2sql","owner":"liamca","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-09T21:14:44.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-19T21:41:39.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liamca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-09T15:15:07.000Z","updated_at":"2024-12-26T15:56:40.000Z","dependencies_parsed_at":"2024-08-09T17:34:18.387Z","dependency_job_id":"f38dd7fa-5ab1-47c0-bf2c-97340f956464","html_url":"https://github.com/liamca/azure_openai_nl2sql","commit_stats":null,"previous_names":["liamca/azure_openai_nl2sql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamca%2Fazure_openai_nl2sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamca%2Fazure_openai_nl2sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamca%2Fazure_openai_nl2sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamca%2Fazure_openai_nl2sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liamca","download_url":"https://codeload.github.com/liamca/azure_openai_nl2sql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243335420,"owners_count":20274904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T23:45:52.000Z","updated_at":"2025-10-27T15:49:30.469Z","avatar_url":"https://github.com/liamca.png","language":"TSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQL Server Schema Description and Query Generation using NL2SQL\n  \nThis project provides a set of tools to generate descriptions for SQL Server tables, create SQL queries based on user natural language questions (NL2SQL), and execute those queries to retrieve and display data. It leverages OpenAI's GPT4 model for generating descriptions and queries.  \n\n*NOTE*: This code has only been tested on Linux (Ubuntu) and may need changes to work on other OS's.\n\n\n\n## Features  \n  \n- Generate detailed descriptions for SQL Server tables to assist Azure OpenAI in generating highly accuracte queries.\n- Create SQL queries based on user questions.  \n- Execute SQL queries and display results in markdown format.  \n- Generate textual answers based on query results.  \n  \n## Setup  \n  \n### Prerequisites  \n  \n- Python 3.7 or higher  \n- Required Python packages: `pyodbc`, `openai`, `pandas`, `IPython`, `tabulate`  \n  \n### Installation and Usage\n  \n1. Clone the repository:  \n    ```sh  \n    git clone [https://github.com/liamca/azure_openai_nl2sql](https://github.com/liamca/azure_openai_nl2sql)  \n    cd azure_openai_nl2sql  \n    ```  \n  \n2. Install the required Python packages and Microsoft SQL ODBC Drivers:  \n    ```sh  \n    pip install pyodbc openai pandas ipython\n\n    sudo apt-get update\n    sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18\n    # optional: for bcp and sqlcmd\n    sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18\n    echo 'export PATH=\"$PATH:/opt/mssql-tools18/bin\"' \u003e\u003e ~/.bashrc\n    source ~/.bashrc\n    # optional: for unixODBC development headers\n    sudo apt-get install -y unixodbc-dev\n    # optional: kerberos library for debian-slim distributions\n    sudo apt-get install -y libgssapi-krb5-2\n    ```  \n\n3. Open the demo notebook [nl2sql.ipynb]([nl2sql.ipynb](https://github.com/liamca/azure_openai_nl2sql/blob/main/nl2sql.ipynb))\n  \n4. Locate the Configuration cell and configure your environment variables:  \n    - `openai_gpt_api_base`  \n    - `openai_gpt_api_key`  \n    - `openai_gpt_api_version`  \n    - `openai_gpt_model`  \n    - `openai_embedding_api_base`  \n    - `openai_embedding_api_key`  \n    - `openai_embedding_api_version`  \n    - `openai_embedding_model`  \n    - `server`  \n    - `database`  \n    - `username`  \n    - `password`  \n\n### Example SQL Query Generation\n![image](https://github.com/user-attachments/assets/50eac200-a567-4887-8e6e-95f2f94e4335)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliamca%2Fazure_openai_nl2sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliamca%2Fazure_openai_nl2sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliamca%2Fazure_openai_nl2sql/lists"}