{"id":25745910,"url":"https://github.com/codera21/text2sql","last_synced_at":"2025-06-26T06:34:40.575Z","repository":{"id":277980771,"uuid":"933046752","full_name":"codera21/text2sql","owner":"codera21","description":"LLM Application that converts text to SQL and execute it","archived":false,"fork":false,"pushed_at":"2025-02-24T11:13:59.000Z","size":94,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T12:26:43.066Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codera21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-15T02:51:29.000Z","updated_at":"2025-02-24T11:14:02.000Z","dependencies_parsed_at":"2025-02-17T11:24:09.071Z","dependency_job_id":"086526d3-9e85-40fc-b70a-337160c2afd1","html_url":"https://github.com/codera21/text2sql","commit_stats":null,"previous_names":["codera21/text2sql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2Ftext2sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2Ftext2sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2Ftext2sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codera21%2Ftext2sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codera21","download_url":"https://codeload.github.com/codera21/text2sql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240843068,"owners_count":19866697,"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":"2025-02-26T11:29:19.258Z","updated_at":"2025-02-26T11:29:19.982Z","avatar_url":"https://github.com/codera21.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# text2sql\n\nLLM Application that converts text to SQL and execute it\n\n## Problem and Approach\n\n### Problem\n\nThe main problem this application aims to solve is the complexity and difficulty of writing SQL queries for users who may not be familiar with SQL syntax. Users often need to extract specific information from databases but lack the expertise to write the necessary SQL queries.\n\n### Approach\n\nThe approach taken to solve this problem involves leveraging a Language Model (LLM) to convert natural language text into SQL queries. This allows users to input their queries in plain English, and the application translates these queries into SQL, executes them, and returns the results.\n\n## Key Implementation Decisions\n\n### Database Choice\n\nDuckDB is used as the database engine due to its efficiency and ease of integration with Python. It supports SQL and is optimized for analytical queries. Since the data was in csv, it support out of the box csv to sql support.\n\n### LLM Integration\n\nThe application integrates with the Gemini LLM to generate SQL queries from user prompts. This involves sending the user prompt to the LLM and receiving the generated SQL query.\n\n### Key assumption\n\n- At the moment, there is no session so the assumption is only a user is using this locally.\n\n### Error handling\n\n- As Gemini is a third party api, I have added retry mechanim for error handling, which will exponentially retry the api.\n\n## Demo\n\n### Running the Application\n\nTo run the application, use the following command:\n- download the dataset from kaggle: https://www.kaggle.com/datasets/usdot/flight-delays/data and keep the csv files in ./dataset folder \n- use your gemini api key as shown in .env.example\n- install poetry and run the command `poetry install`\n- finally run the application via the command\n\n```sh\npython src/api.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodera21%2Ftext2sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodera21%2Ftext2sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodera21%2Ftext2sql/lists"}