ormGPT
1.0.0
일반적인 인간 언어를 SQL 쿼리로 변환하고 데이터베이스에서 실행하는 OpenAI를 기반으로 한 ORM.
현재 데이터베이스 방언 : MySQL, PostgreSQL 및 SQLite를 지원합니다.
지원되는 언어 : 영어, 독일어, 프랑스어, 스페인어, 폴란드어, 이탈리아어, 네덜란드어, 포르투갈어, 우크라이나, 아랍어, 중국어, 일본어, 한국, 터키어 등.
ormgpt.query( " give me post with id 1, all comments for this post and user information about author " ) ;생성 쿼리 :
SELECT
p . id AS post_id,
p . title ,
p . body ,
c . id AS comment_id,
c . body AS comment_body,
u . username AS author_username,
u . email AS author_email
FROM
posts p
JOIN comments c ON p . id = c . post_id
JOIN users u ON u . id = p . user_id
WHERE
p . id = 1 ;응답:
[
{
post_id : 1 ,
title : 'Hello world!' ,
body : 'This is my first post!' ,
comment_id : 1 ,
comment_body : 'Hello world!' ,
author_username : 'test' ,
author_email : '[email protected]'
}
] 
npm install ormgpt
# or
yarn add ormgpt
# or
pnpm add ormgpt 데이터베이스 스키마 파일 (예 : schema.sql )을 준비하십시오. 이 파일은 쿼리를 생성하는 데 사용됩니다.
const client = await createConnection ( {
host : 'localhost' ,
port : 3306 ,
database : 'ormgpt' ,
user : 'root' ,
password : 'mysecretpassword' ,
} ) ;
const mysqlAdapter = new MysqlAdapter ( {
client
} ) ;
const ormgpt = new ormGPT ( {
apiKey : "OPENAI_API_KEY" ,
schemaFilePath : "./example/schema.sql" ,
dialect : "postgres" ,
dbEngineAdapter : mysqlAdapter ,
} ) ;
await ormgpt . query (
"add new user with username 'test' and email '[email protected]'" ,
) ;
const users = await ormgpt . query ( "get all users" ) ;
console . log ( users ) ;MySQL
const client = await createConnection ( {
host : 'localhost' ,
port : 3306 ,
database : 'ormgpt' ,
user : 'root' ,
password : 'mysecretpassword' ,
} ) ;
const mysqlAdapter = new MysqlAdapter ( {
client
} ) ;포스트 그레스
const client = new Client ( {
host : 'localhost' ,
port : 5432 ,
database : 'ormgpt' ,
user : 'mysecretuser' ,
password : 'mysecretpassword' ,
} ) ;
client . connect ( ) ;
const postgresAdapter = new PostgresAdapter ( {
client
} ) ;sqlite
const sqliteAdapter = new SqliteAdapter ( {
dbFilePath : "./example/db.sqlite" ,
} ) ;지난 2 년 동안, 나는 Orms가 JavaScript Ecosystem의 새로운 "마지막 JavaScript 프레임 워크 이후"인 것을 발견했습니다. AI는 핫 버즈 라기 때문에 두 가지를 결합하고 SQL 쿼리를 생성하기 위해 OpenAI를 사용하는 ORM을 만들기 위해 조금 실험하기로 결정했습니다. 제작에 이것을 사용하지 마십시오.
MIT