{"id":15041118,"url":"https://github.com/pilotpirxie/ormgpt","last_synced_at":"2025-04-14T19:36:30.188Z","repository":{"id":199928232,"uuid":"704101345","full_name":"pilotpirxie/ormGPT","owner":"pilotpirxie","description":"An ORM based on OpenAI that translates plain language into SQL queries and executes them on a database.","archived":false,"fork":false,"pushed_at":"2023-10-12T19:57:15.000Z","size":3048,"stargazers_count":57,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T08:01:46.447Z","etag":null,"topics":["chatgpt","database","database-management","db","gpt","gpt-3","gpt-4","orm","orm-framework","orms","query"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pilotpirxie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-12T14:37:02.000Z","updated_at":"2025-02-13T04:45:08.000Z","dependencies_parsed_at":"2023-10-14T07:58:34.994Z","dependency_job_id":null,"html_url":"https://github.com/pilotpirxie/ormGPT","commit_stats":null,"previous_names":["pilotpirxie/ormgpt"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2FormGPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2FormGPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2FormGPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pilotpirxie%2FormGPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pilotpirxie","download_url":"https://codeload.github.com/pilotpirxie/ormGPT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248946857,"owners_count":21187586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","database","database-management","db","gpt","gpt-3","gpt-4","orm","orm-framework","orms","query"],"created_at":"2024-09-24T20:45:37.172Z","updated_at":"2025-04-14T19:36:30.162Z","avatar_url":"https://github.com/pilotpirxie.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ormGPT\n\nAn ORM based on OpenAI that translates plain human language into SQL queries and executes them on a database.\n\nCurrently supports database dialects: MySQL, PostgreSQL, and SQLite.\n\nSupported languages: English, German, French, Spanish, Polish, Italian, Dutch, Portuguese, Ukrainian, Arabic, Chinese, Japanese, Korean, Turkish and many more.\n\n```shell\normgpt.query(\"give me post with id 1, all comments for this post and user information about author\");\n```\n\nGenerated query:\n```sql\nSELECT \n  p.id AS post_id, \n  p.title, \n  p.body, \n  c.id AS comment_id, \n  c.body AS comment_body, \n  u.username AS author_username, \n  u.email AS author_email \nFROM \n  posts p \n  JOIN comments c ON p.id = c.post_id \n  JOIN users u ON u.id = p.user_id \nWHERE \n  p.id = 1;\n```\n\nResponse:\n```js\n[\n  {\n    post_id: 1,\n    title: 'Hello world!',\n    body: 'This is my first post!',\n    comment_id: 1,\n    comment_body: 'Hello world!',\n    author_username: 'test',\n    author_email: 'test@example.com'\n  }\n]\n```\n\n![./preview.gif](./preview.gif)\n\n## Installation\n\n```shell\nnpm install ormgpt\n\n# or\n\nyarn add ormgpt\n\n# or\n\npnpm add ormgpt\n```\n\n## Usage\nPrepare a database schema file, for example `schema.sql`. This file will be used to generate queries.\n\n```js\n  const client = await createConnection({\n    host: 'localhost',\n    port: 3306,\n    database: 'ormgpt',\n    user: 'root',\n    password: 'mysecretpassword',\n  });\n\n  const mysqlAdapter = new MysqlAdapter({\n    client\n  });\n\n  const ormgpt = new ormGPT({\n    apiKey: \"OPENAI_API_KEY\",\n    schemaFilePath: \"./example/schema.sql\",\n    dialect: \"postgres\",\n    dbEngineAdapter: mysqlAdapter,\n  });\n\n  await ormgpt.query(\n    \"add new user with username 'test' and email 'test@example.com'\",\n  );\n    \n  const users = await ormgpt.query(\"get all users\");\n  console.log(users);\n```\n\n### Adapters\n\nMySQL\n```js\nconst client = await createConnection({\n  host: 'localhost',\n  port: 3306,\n  database: 'ormgpt',\n  user: 'root',\n  password: 'mysecretpassword',\n});\n\nconst mysqlAdapter = new MysqlAdapter({\n  client\n});\n```\n\nPostgres\n```js\nconst client = new Client({\n  host: 'localhost',\n  port: 5432,\n  database: 'ormgpt',\n  user: 'mysecretuser',\n  password: 'mysecretpassword',\n});\nclient.connect();\n\nconst postgresAdapter = new PostgresAdapter({\n  client\n});\n```\n\nSQLite\n```js\nconst sqliteAdapter = new SqliteAdapter({\n  dbFilePath: \"./example/db.sqlite\",\n});\n```\n\n### Why?\n\nIn the last two years, I found ORMs to be new \"days since the last javascript framework\" in the JavaScript ecosystem. And since AI is a hot buzzword\nI decided to experiment a little to combine both and create an ORM that uses OpenAI to generate SQL queries. Please don't use this in production.\n\n### License\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilotpirxie%2Formgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpilotpirxie%2Formgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilotpirxie%2Formgpt/lists"}