NLSQL
Generates SQL query from natural language for your PostrgreSQL database. Simply connects to your database, gets the schema and generates query appropriately.
User Guide
you can use nlsql as httpserver and as a cli-command
Installation
pip install nlsql
run as http server
- start up the api server
nlsql -s - get results via curl
curl --location 'http://localhost:8000/query' \ --header 'Content-Type: application/json' \ --data-raw '{ "question": "get users with post that has top views and top reactions in the last 24 hours", "db_url": "postgresql://postgres:postgres@localhost:5432/postgres" }'
run as cli command
nlsql -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"
Response
SELECT DISTINCT ON (users.id) users.id, users.name
FROM users
JOIN posts ON users.id = posts.post_creator_user_id
WHERE posts.created_at > now() - interval '1 day'
GROUP BY users.id, users.name
HAVING SUM(posts.views) >= ALL (SELECT SUM(views) FROM posts WHERE created_at > now() - interval '1 day') AND SUM(posts.reactions) >= ALL (SELECT SUM(reactions) FROM posts WHERE created_at > now() - interval '1 day');
response was generated over the following users and posts tables:
postgres=# \d users
Column | Type | Collation | Nullable | Default
------------+-----------------------------+-----------+----------+-----------------------------------
id | integer | | not null | nextval('users_id_seq'::regclass)
name | text | | |
created_at | timestamp without time zone | | |
postgres=# \d posts
Column | Type | Collation | Nullable | Default
----------------------+-----------------------------+-----------+----------+-----------------------------------
id | integer | | not null | nextval('posts_id_seq'::regclass)
title | text | | |
url | text | | |
post_creator_user_id | integer | | |
views | integer | | |
reactions | integer | | |
created_at | timestamp without time zone | | |
updated_at | timestamp without time zone | | |
Metadata
Release files for nlsql 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nlsql-0.0.2.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nlsql-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.2 kB
Release files / nlsql-0.0.2.tar.gz
| Download URL | nlsql-0.0.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e8abc01f3e2e5157dac831d60cafffbcd90321a723b110483cfd160bc60f2fc
|
|
BLAKE2b-256 checksum How to use checksums |
862d950ca49b54ac27b868f90969091884533ff478b90fca91f1e32aeb55205c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Release files / nlsql-0.0.2-py3-none-any.whl
| Download URL | nlsql-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d098ab3a40e6d1e5d2f61e49b60751d0400dd843ed0fa760ff61b3e2ff92db9c
|
|
BLAKE2b-256 checksum How to use checksums |
6cc37e094dbab2e3eccd48e5da0212a7ec5a1b5a9f2730b1dfe5ee2a34c3e7e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.12
|
Security for nlsql 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.