sql2gpt


Namesql2gpt JSON
Version 0.3.1 PyPI version JSON
download
home_page
SummaryA tool to extract SQL database schema and generate ChatGPT prompts
upload_time2023-04-17 23:42:20
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT
keywords sql chatgpt database schema
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SQL2GPT

SQL2GPT is a Python-based tool that extracts the schema of a SQL database and generates a prompt for ChatGPT, a large language model by OpenAI. The goal of this project is to enable users to interact with ChatGPT to generate code or ask questions related to the given database schema.

![Example](tapes/demo.gif)

## Table of Contents

* [Prerequisites](#prerequisites)
* [Installation](#installation)
* [Usage](#usage)
  + [Adding a Database Connection](#adding-a-database-connection)
  + [Printing the Schema](#printing-the-schema)
  + [Generating the ChatGPT Prompt](#generating-the-chatgpt-prompt)
* [License](#license)

## Prerequisites

* Python 3.11 or higher
* MySQL client (for MySQL databases)
* Pipenv: A Python dependency management tool

## Installation

First, clone the repository:

```bash
git clone https://github.com/chand1012/sql2gpt.git
cd sql2gpt
```

Ensure that you have pipenv installed. If you don't have it installed, you can install it using pip:

```bash
pip install pipenv
```

Once you have pipenv installed, set up the environment and install the dependencies:

```bash
pipenv install
```

To activate the virtual environment, run:

```bash
pipenv shell
```

## Usage

### Adding a Database Connection

Add a new database connection by running:

```bash
python sql2gpt.py add <name> <database_uri>
```

Where `<name>` is the name you want to give to the connection, and `<database_uri>` is the URI for the database, such as:

* PostgreSQL: `postgresql://username:password@localhost/dbname`
* MySQL: `mysql://username:password@localhost/dbname`
* SQLite: `sqlite:///example.db`

### Printing the Schema

To print the schema of a database, run:

```bash
python sql2gpt.py print_schema <database_url or name>
```

Replace <database_url> with the appropriate database URL for your SQL database or the name of the connection you added previously.

### Generating the ChatGPT Prompt

To generate the ChatGPT prompt for a given database, run:

```bash
python sql2gpt.py get_prompt <database_url or name>
```

Replace <database_url> with the appropriate database URL for your SQL database or the name of the connection you added previously. The generated prompt can be passed to ChatGPT to obtain code or ask questions about the database.

## License

This project is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sql2gpt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "sql,chatgpt,database,schema",
    "author": "",
    "author_email": "Your Name <your.email@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/50/3e/23bca3bb53cae3c4fc0e939a7676501c0491410a2d9a7d5acc457e25bea7/sql2gpt-0.3.1.tar.gz",
    "platform": null,
    "description": "# SQL2GPT\n\nSQL2GPT is a Python-based tool that extracts the schema of a SQL database and generates a prompt for ChatGPT, a large language model by OpenAI. The goal of this project is to enable users to interact with ChatGPT to generate code or ask questions related to the given database schema.\n\n![Example](tapes/demo.gif)\n\n## Table of Contents\n\n* [Prerequisites](#prerequisites)\n* [Installation](#installation)\n* [Usage](#usage)\n  + [Adding a Database Connection](#adding-a-database-connection)\n  + [Printing the Schema](#printing-the-schema)\n  + [Generating the ChatGPT Prompt](#generating-the-chatgpt-prompt)\n* [License](#license)\n\n## Prerequisites\n\n* Python 3.11 or higher\n* MySQL client (for MySQL databases)\n* Pipenv: A Python dependency management tool\n\n## Installation\n\nFirst, clone the repository:\n\n```bash\ngit clone https://github.com/chand1012/sql2gpt.git\ncd sql2gpt\n```\n\nEnsure that you have pipenv installed. If you don't have it installed, you can install it using pip:\n\n```bash\npip install pipenv\n```\n\nOnce you have pipenv installed, set up the environment and install the dependencies:\n\n```bash\npipenv install\n```\n\nTo activate the virtual environment, run:\n\n```bash\npipenv shell\n```\n\n## Usage\n\n### Adding a Database Connection\n\nAdd a new database connection by running:\n\n```bash\npython sql2gpt.py add <name> <database_uri>\n```\n\nWhere `<name>` is the name you want to give to the connection, and `<database_uri>` is the URI for the database, such as:\n\n* PostgreSQL: `postgresql://username:password@localhost/dbname`\n* MySQL: `mysql://username:password@localhost/dbname`\n* SQLite: `sqlite:///example.db`\n\n### Printing the Schema\n\nTo print the schema of a database, run:\n\n```bash\npython sql2gpt.py print_schema <database_url or name>\n```\n\nReplace <database_url> with the appropriate database URL for your SQL database or the name of the connection you added previously.\n\n### Generating the ChatGPT Prompt\n\nTo generate the ChatGPT prompt for a given database, run:\n\n```bash\npython sql2gpt.py get_prompt <database_url or name>\n```\n\nReplace <database_url> with the appropriate database URL for your SQL database or the name of the connection you added previously. The generated prompt can be passed to ChatGPT to obtain code or ask questions about the database.\n\n## License\n\nThis project is licensed under the MIT License.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A tool to extract SQL database schema and generate ChatGPT prompts",
    "version": "0.3.1",
    "split_keywords": [
        "sql",
        "chatgpt",
        "database",
        "schema"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "932929e7ea01017d1ae07ea608e3705b30d5a1a66caa26f9e6a306d05a75c52f",
                "md5": "46e492caabdf3d20ce17368f0cccd8a7",
                "sha256": "0627a86f7b3cc9101033e8d34269804bdeeb2f6a8f81fd368121e5a2245018a1"
            },
            "downloads": -1,
            "filename": "sql2gpt-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "46e492caabdf3d20ce17368f0cccd8a7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 453245,
            "upload_time": "2023-04-17T23:42:18",
            "upload_time_iso_8601": "2023-04-17T23:42:18.199232Z",
            "url": "https://files.pythonhosted.org/packages/93/29/29e7ea01017d1ae07ea608e3705b30d5a1a66caa26f9e6a306d05a75c52f/sql2gpt-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "503e23bca3bb53cae3c4fc0e939a7676501c0491410a2d9a7d5acc457e25bea7",
                "md5": "6727b6c1121a87006cceffa3391926df",
                "sha256": "c4e4b36d8fe4c19eb10be1078bcd44a0f412a77b49e7932c4928a4b033e3daf5"
            },
            "downloads": -1,
            "filename": "sql2gpt-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6727b6c1121a87006cceffa3391926df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 468954,
            "upload_time": "2023-04-17T23:42:20",
            "upload_time_iso_8601": "2023-04-17T23:42:20.268690Z",
            "url": "https://files.pythonhosted.org/packages/50/3e/23bca3bb53cae3c4fc0e939a7676501c0491410a2d9a7d5acc457e25bea7/sql2gpt-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-17 23:42:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "sql2gpt"
}
        
Elapsed time: 0.05900s