{"id":25177876,"url":"https://github.com/prashantbtkl/nlsql","last_synced_at":"2025-05-07T02:41:31.274Z","repository":{"id":234239727,"uuid":"788496941","full_name":"PrashantBtkl/nlsql","owner":"PrashantBtkl","description":"generates SQL query from natural language for your PostrgreSQL database","archived":false,"fork":false,"pushed_at":"2024-08-27T06:29:13.000Z","size":41,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T05:31:52.220Z","etag":null,"topics":["llm","llm-inference","postgres","postgresql","sql","text-to-sql"],"latest_commit_sha":null,"homepage":"","language":"Python","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/PrashantBtkl.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-04-18T14:28:42.000Z","updated_at":"2025-01-12T14:06:53.000Z","dependencies_parsed_at":"2024-05-12T07:30:19.373Z","dependency_job_id":"9d07545a-5504-4557-b00e-32a88e33da70","html_url":"https://github.com/PrashantBtkl/nlsql","commit_stats":null,"previous_names":["prashantbtkl/nlsql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrashantBtkl%2Fnlsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrashantBtkl%2Fnlsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrashantBtkl%2Fnlsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PrashantBtkl%2Fnlsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PrashantBtkl","download_url":"https://codeload.github.com/PrashantBtkl/nlsql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252802511,"owners_count":21806518,"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":["llm","llm-inference","postgres","postgresql","sql","text-to-sql"],"created_at":"2025-02-09T14:49:49.741Z","updated_at":"2025-05-07T02:41:31.250Z","avatar_url":"https://github.com/PrashantBtkl.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n\n\u003ch1 align=\"center\"\u003eNLSQL\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\n \u003cdiv align=\"center\"\u003e\n\t \n[![PyPi package version](https://img.shields.io/pypi/v/nlsql)](https://pypi.org/project/nlsql/)\t \n[![PyPi downloads](https://static.pepy.tech/badge/nlsql)](https://pypi.org/project/nlsql/)\n[![License](https://img.shields.io/pypi/l/nlsql)](https://pypi.org/project/nlsql/)\t \n[![PyPI version](https://img.shields.io/pypi/pyversions/nlsql?color=%2344CC11\u0026style=flat-square)](https://pypi.org/project/nlsql/)\n \u003c/div\u003e\n\u003cbr\u003e\n\n\nGenerates SQL query from natural language for your PostrgreSQL database. \nSimply connects to your database, gets the schema and generates query appropriately.\n\n## User Guide\n\nyou can use nlsql as httpserver and as a cli-command\n\n## Installation\n```bash\npip install nlsql\n```\n\n## run as http server\n1. start up the api server\n\t```bash\n\tnlsql -s\n\t```\n2. get results via curl\n\t```curl\n\tcurl --location 'http://localhost:8000/query' \\\n\t--header 'Content-Type: application/json' \\\n\t--data-raw '{\n\t\"question\": \"get users with post that has top views and top reactions in the last 24 hours\",\n\t\"db_url\": \"postgresql://postgres:postgres@localhost:5432/postgres\"\n\t}'\n\t```\n\n## run as cli command\n\n```bash\nnlsql -m \"./Nous-Hermes-2-Mistral-7B-DPO.Q4_0.gguf\" -d \"postgresql://postgres:postgres@localhost:5432/postgres\" -q \"get users with post that has top views and top reactions in the last 24 hours\"\n```\n## Response\n```sql\n    SELECT DISTINCT ON (users.id) users.id, users.name\n    FROM users\n    JOIN posts ON users.id = posts.post_creator_user_id\n    WHERE posts.created_at \u003e now() - interval '1 day'\n    GROUP BY users.id, users.name\n    HAVING SUM(posts.views) \u003e= ALL (SELECT SUM(views) FROM posts WHERE created_at \u003e now() - interval '1 day') AND SUM(posts.reactions) \u003e= ALL (SELECT SUM(reactions) FROM posts WHERE created_at \u003e now() - interval '1 day');\n```\n\nresponse was generated over the following `users` and `posts` tables:\n```\npostgres=# \\d users\n   Column   |            Type             | Collation | Nullable |              Default              \n------------+-----------------------------+-----------+----------+-----------------------------------\n id         | integer                     |           | not null | nextval('users_id_seq'::regclass)\n name       | text                        |           |          | \n created_at | timestamp without time zone |           |          | \n\npostgres=# \\d posts\n        Column        |            Type             | Collation | Nullable |              Default              \n----------------------+-----------------------------+-----------+----------+-----------------------------------\n id                   | integer                     |           | not null | nextval('posts_id_seq'::regclass)\n title                | text                        |           |          | \n url                  | text                        |           |          | \n post_creator_user_id | integer                     |           |          | \n views                | integer                     |           |          | \n reactions            | integer                     |           |          | \n created_at           | timestamp without time zone |           |          | \n updated_at           | timestamp without time zone |           |          | \n\n ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprashantbtkl%2Fnlsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprashantbtkl%2Fnlsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprashantbtkl%2Fnlsql/lists"}