sqlitegpt

0.1.1 • Public • Published

SQLiteGPT

SQL function for SQLite to directly query OpenAI's ChatGPT.

CLI

Installation

npm install --global sqlitegpt

Usage

export OPENAI_API_KEY="sk-XXX"
sqlitegpt example.sqlite "SELECT gpt('Name of tallest mountain')"

Library Usage

import { sqliteGpt } from "sqlitegpt"

sqliteGpt(
  ":memory:",
  "SELECT gpt('Name of tallest mountain') as tallest_mountain"
)

sqliteGpt(
  "example.sqlite",
  `
    SELECT
      country,
      gpt('capital of ' || country || ', no explanation') as capital
    FROM users
  `
)

Known Issues

  • This implementation currently uses sync-request which forces HTTP requests to be synchronous. You should not use this in production! However, it's currently the only way to make it work with better-sqlite3.
  • It's only implemented as an application-defined SQL function and can therefore only be used in JavaScript projects. To make it work in every SQLite environment, it should be implemented as a loadable extension.

If you like SQLiteGPT, please star the project and I will re-implement it as a proper loadable extension in Rust with sqlite-loadable-rs.


Package Sidebar

Install

npm i sqlitegpt

Weekly Downloads

1

Version

0.1.1

License

ISC

Unpacked Size

16.8 kB

Total Files

5

Last publish

Collaborators

  • adius