https://github.com/harryvolek/aisql
Use GPT to generate SQL
https://github.com/harryvolek/aisql
chatgpt gpt-3 postgres psql sql text2sql
Last synced: 12 months ago
JSON representation
Use GPT to generate SQL
- Host: GitHub
- URL: https://github.com/harryvolek/aisql
- Owner: HarryVolek
- License: mit
- Created: 2023-01-27T04:36:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T21:42:03.000Z (about 3 years ago)
- Last Synced: 2025-03-26T07:36:30.144Z (about 1 year ago)
- Topics: chatgpt, gpt-3, postgres, psql, sql, text2sql
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Convert text prompts to sql for your postgres db.
Grabs database DDL to use in the GPT prompts, creating working queries.
To run:
`
go run aisql.go -K [openai auth key] -C '[postgres connection string]'
`
Example:
```
-> Give me all animals who's name starts with D
Response start=======
SELECT *
FROM animals
WHERE name LIKE 'D%' -- This query will return all animals whose name starts with the letter D. The LIKE operator is used to search for a pattern in a column. The '%' wildcard character is used to match any number of characters after the letter D.
Response finish======
Execute query? [y/N]
y
id | name | type | age | registered_at | image | owner_id
-----+-----------+----------+-----+--------------------------+----------------------------------+----------
54 | Devon Rex | insect | 14 | 2021-06-18T20:40:34.991Z | http://placeimg.com/640/480/cats | 17
104 | Devon Rex | cetacean | 4 | 2021-11-02T06:34:56.853Z | http://placeimg.com/640/480/cats | 37
(2 rows)
->
```