Metadata-Version: 2.1
Name: gptsql
Version: 0.1.1
Summary: LLM helper for psql
Author: Scott Persinger
Author-email: scottpersinger@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: halo (>=0.0.31,<0.0.32)
Requires-Dist: openai (>=1.3.6,<2.0.0)
Requires-Dist: pandas (>=2.1.3,<3.0.0)
Requires-Dist: prompt-toolkit (>=3.0.41,<4.0.0)
Requires-Dist: psycopg2 (>=2.9.9,<3.0.0)
Requires-Dist: sqlalchemy (>=2.0.23,<3.0.0)
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
Requires-Dist: termcolor (>=2.3.0,<3.0.0)
Description-Content-Type: text/markdown

# gptsql

An LLM wrapper around your database connection. Think of it as a "smart" version of the psql cli.

Example:

```
    python -m gptsql
    > show me the schemas
    thinking...
    Running select query: SELECT schema_name FROM information_schema.schemata;
    processing the function response...
    Here are the schemas in your database:

    1. pg_catalog
    2. information_schema
    3. analytics
    4. public
    5. aws_commons
    6. bi_staging
    7. rds_tools

    > show me all the tables with 'sales' in the name
    ⠸ thinking...  Running select query: SELECT table_name FROM information_schema.tables WHERE table_name LIKE '%%sales%%' ORDER BY table_name;
    [assistant] --> The tables with 'sales' in the name are as follows:

    - salesorderdetail
    - salesorderheader
    - salesorderheadersalesreason
    - salesperson
    - salespersonquotahistory
    - salesreason
    - salestaxrate
    - salesterritory
    - salesterritoryhistory
    - vsalesperson
    - vsalespersonsalesbyfiscalyears
    - vsalespersonsalesbyfiscalyearsdata

    > how many rows are in the salesperson table?
    ⠏ thinking...  Running select query: SELECT COUNT(*) FROM sales.salesperson;
    [assistant] --> The `salesperson` table contains 17 rows.
```

## Getting started

You need credentials for your database, and you will need an OpenAI **API Key** from your OpenAI account.

Installation:

    pip install gptsql

or download the source. 

Run the CLI with:

    gptsql

or use `python -m gptsql` to run from source.

