{"id":26842396,"url":"https://github.com/lankesathwik7/sql-query-assistant","last_synced_at":"2026-04-29T13:33:19.813Z","repository":{"id":275086005,"uuid":"924968206","full_name":"LankeSathwik7/sql-query-assistant","owner":"LankeSathwik7","description":"Natural language to SQL query converter using Groq LLM. Ask questions in plain English and get SQL queries, visualized results, and natural language explanations. Built with Streamlit and PostgreSQL.","archived":false,"fork":false,"pushed_at":"2025-01-31T18:44:30.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-12T05:08:10.989Z","etag":null,"topics":["data-analysis","database","groq","llm","natural-language-processing","python","sql"],"latest_commit_sha":null,"homepage":"https://sql-query-assistant.streamlit.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LankeSathwik7.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-31T00:48:57.000Z","updated_at":"2025-02-12T02:19:44.000Z","dependencies_parsed_at":"2025-06-12T05:08:14.767Z","dependency_job_id":"3a6edd05-4ab3-4aa4-a50e-062c48b5149b","html_url":"https://github.com/LankeSathwik7/sql-query-assistant","commit_stats":null,"previous_names":["lankesathwik7/sql-query-assistant"],"tags_count":0,"template":false,"template_full_name":"streamlit/blank-app-template","purl":"pkg:github/LankeSathwik7/sql-query-assistant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LankeSathwik7%2Fsql-query-assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LankeSathwik7%2Fsql-query-assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LankeSathwik7%2Fsql-query-assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LankeSathwik7%2Fsql-query-assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LankeSathwik7","download_url":"https://codeload.github.com/LankeSathwik7/sql-query-assistant/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LankeSathwik7%2Fsql-query-assistant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32427578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T12:24:25.982Z","status":"ssl_error","status_checked_at":"2026-04-29T12:24:24.439Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data-analysis","database","groq","llm","natural-language-processing","python","sql"],"created_at":"2025-03-30T18:19:58.366Z","updated_at":"2026-04-29T13:33:19.795Z","avatar_url":"https://github.com/LankeSathwik7.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 SQL Query Assistant\n\nA Streamlit-based application that allows users to query their PostgreSQL database using natural language questions. The app leverages the Groq LLM API to convert natural language queries into SQL and provide human-readable answers.\n\n## ✨ Features\n\n- 🤖 Natural language to SQL conversion\n- 📊 Interactive database schema visualization\n- 📈 Real-time query results with data visualization\n- 💾 CSV export functionality\n- 🔍 Sample data preview for all tables\n- 📝 Detailed database statistics\n- 🔗 Table relationship visualization\n\n## 📋 Prerequisites\n\n- Python 3.8+\n- PostgreSQL database\n- Groq API key\n- Streamlit account (for secrets management)\n\n## 🚀 Installation\n\n1. Clone the repository:\n```bash\ngit clone \u003crepository-url\u003e\ncd sql-query-assistant\n```\n\n2. Install required packages:\n```bash\npip install -r requirements.txt\n```\n\n3. Set up your environment variables in `.streamlit/secrets.toml`:\n```toml\nDATABASE_URL = \"your-postgresql-connection-string\"\nDATABASE_NAME = \"your-database-name\"\nGROQ_API_KEY = \"your-groq-api-key\"\n```\n\n## 📂 Project Structure\n\n```\n.\n├── LICENSE                 # Apache License 2.0\n├── README.md              # Project documentation\n├── requirements.txt       # Project dependencies\n├── src/\n│   ├── __init__.py\n│   ├── database.py       # Database connection and operations\n│   └── llm_chain.py      # LLM integration and query processing\n└── streamlit_app.py      # Main Streamlit application\n```\n\n## ⚙️ Configuration\n\n### 🗄️ Database Connection\n\nThe application uses PostgreSQL as its database. Configure your database connection in `.streamlit/secrets.toml`:\n\n```toml\nDATABASE_URL = \"postgresql://username:password@host:port/database?sslmode=require\"\nDATABASE_NAME = \"Your Database Name\"\n```\n\n### 🧠 LLM Integration\n\nThe application uses Groq's LLM API for natural language processing. Add your API key to `.streamlit/secrets.toml`:\n\n```toml\nGROQ_API_KEY = \"your-groq-api-key\"\n```\n\n## 📦 Required Dependencies\n\nThe following packages are required and can be installed via requirements.txt:\n- streamlit\n- psycopg2-binary\n- google-generativeai\n- pandas\n- groq\n\n## 🏃‍♂️ Running the Application\n\n1. Start the Streamlit application:\n```bash\nstreamlit run streamlit_app.py\n```\n\n2. Open your browser and navigate to the provided URL (typically http://localhost:8501)\n\n## 📱 Usage\n\n1. **View Database Schema**: \n   - The sidebar displays all tables, their columns, and relationships\n   - Sample data is available for each table\n   - Database statistics show total tables, rows, and database size\n\n2. **Query Your Data**:\n   - Enter your question in natural language\n   - Click \"Get Answer\" to process your query\n   - View the generated SQL, results table, and natural language explanation\n   - Download results as CSV if needed\n\n3. **Example Questions**:\n   - \"Show total revenue by category\"\n   - \"Which products have the highest sales quantity?\"\n   - \"List top 5 customers by order value\"\n\n## 🔒 Security Features\n\n- SQL injection prevention through proper query sanitization\n- Secure credential management using Streamlit secrets\n- Parameterized queries for safe database operations\n\n## 🔧 Technical Details\n\n### 🧩 Components\n\n1. **database.py**:\n   - Handles all database operations\n   - Manages connections and queries\n   - Provides schema information\n\n2. **llm_chain.py**:\n   - Processes natural language questions\n   - Generates SQL queries using Groq LLM\n   - Creates natural language responses\n\n3. **streamlit_app.py**:\n   - Main application interface\n   - Handles user interaction\n   - Displays results and visualizations\n\n### ⚡ Query Processing Flow\n\n1. User inputs a natural language question\n2. System generates database schema context\n3. Groq LLM converts question to SQL\n4. Query is validated and executed\n5. Results are formatted and displayed\n6. Natural language explanation is generated\n\n## ⚠️ Error Handling\n\n- Database connection errors are gracefully handled\n- Invalid queries are caught and reported\n- LLM API errors are managed with appropriate user feedback\n\n## 🤝 Contributing\n\nPlease feel free to submit issues and pull requests for any improvements.\n\n## 📄 License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Built with [Streamlit](https://streamlit.io/)\n- Powered by [Groq](https://groq.com/) LLM API\n- Uses [PostgreSQL](https://www.postgresql.org/) for database management","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flankesathwik7%2Fsql-query-assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flankesathwik7%2Fsql-query-assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flankesathwik7%2Fsql-query-assistant/lists"}