{"id":42571,"library":"cyber-mysql-openai","title":"Cyber-MySQL-OpenAI","description":"Cyber-MySQL-OpenAI is a Node.js library that translates natural language questions into SQL, executes them against MySQL databases, and returns results with human-readable explanations. Version 0.3.3 provides features such as self-correcting error handling (up to 3 reflection attempts), structured output via OpenAI function calling, business context awareness, foreign key relationship detection, confidence scoring, multi-language support (English and Spanish), in-memory caching, token optimization, and query validation. It is actively maintained with frequent updates and full TypeScript support.","status":"active","version":"0.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/dannyusca/cyber-mysql-openai","tags":["javascript","sql","natural-language","natural-language-processing","nlp","openai","gpt","gpt-4","chatgpt","typescript"],"install":[{"cmd":"npm install cyber-mysql-openai","lang":"bash","label":"npm"},{"cmd":"yarn add cyber-mysql-openai","lang":"bash","label":"yarn"},{"cmd":"pnpm add cyber-mysql-openai","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for connecting to and querying MySQL databases.","package":"mysql2","optional":false},{"reason":"Required for interacting with OpenAI's API for natural language processing.","package":"openai","optional":false}],"imports":[{"note":"The main class is exported as a named export. Default import is not available.","wrong":"import CyberMySQLOpenAI from 'cyber-mysql-openai'","symbol":"Translator","correct":"import { Translator } from 'cyber-mysql-openai'"},{"note":"TranslatorConfig is a TypeScript type. Use `import type` when only needing the type.","wrong":"import { TranslatorConfig } from 'cyber-mysql-openai'","symbol":"TranslatorConfig","correct":"import type { TranslatorConfig } from 'cyber-mysql-openai'"},{"note":"QueryResult is a TypeScript type representing the result of a query execution.","wrong":"","symbol":"QueryResult","correct":"import type { QueryResult } from 'cyber-mysql-openai'"}],"quickstart":{"code":"import { Translator } from 'cyber-mysql-openai';\n\nconst translator = new Translator({\n  mysql: {\n    host: process.env.MYSQL_HOST ?? 'localhost',\n    user: process.env.MYSQL_USER ?? 'root',\n    password: process.env.MYSQL_PASSWORD ?? '',\n    database: process.env.MYSQL_DATABASE ?? 'test'\n  },\n  openai: {\n    apiKey: process.env.OPENAI_API_KEY ?? ''\n  }\n});\n\nasync function main() {\n  const result = await translator.query('How many users registered last month?');\n  console.log(result);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates initializing a Translator with MySQL and OpenAI configs, then querying for user registrations."},"warnings":[{"fix":"Wrap your config as { mysql: {...}, openai: {...} }","message":"Version 0.3.0 changed the constructor signature requiring nested 'mysql' and 'openai' objects. Older config flattened is not supported.","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"Specify a compatible model in translator config: { openai: { model: 'gpt-4' } }","message":"The library uses OpenAI function calling and expects a model that supports it (e.g., gpt-3.5-turbo or gpt-4). Using incompatible models will cause errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Implement external caching (e.g., Redis) if persistence is needed.","message":"The cache is in-memory and not persisted. Restarting the application clears all cached data.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'-4':104 '0.3.3':34 '3':46 'activ':82 'attempt':48 'awar':57 'busi':55 'cach':74 'call':54 'chatgpt':105 'confid':62 'context':56 'correct':41 'cyber':2,6 'cyber-mysql-openai':1,5 'databas':24 'detect':61 'english':68 'error':42 'execut':20 'explan':32 'featur':36 'foreign':58 'frequent':85 'full':88 'function':53 'gpt':102,103 'handl':43 'human':30 'human-read':29 'in-memori':71 'javascript':91 'key':59 'languag':16,66,95,98 'librari':12 'maintain':83 'memori':73 'multi':65 'multi-languag':64 'mysql':3,7,23 'natur':15,94,97 'natural-languag':93 'natural-language-process':96 'nlp':100 'node.js':11 'openai':4,8,52,101 'optim':76 'output':50 'process':99 'provid':35 'queri':78 'question':17 'readabl':31 'reflect':47 'relationship':60 'result':27 'return':26 'score':63 'self':40 'self-correct':39 'spanish':70 'sql':19,92 'structur':49 'support':67,90 'token':75 'translat':14 'typescript':89,106 'updat':86 'valid':79 'version':33 'via':51","created_at":"2026-06-05T16:55:37.571247+00:00","updated_at":"2026-06-05T16:55:37.571247+00:00","problems":[{"fix":"Run: npm install cyber-mysql-openai","cause":"Package not installed or not imported correctly.","error":"Error: Cannot find module 'cyber-mysql-openai'"},{"fix":"Use: import { Translator } from 'cyber-mysql-openai'","cause":"Using default import instead of named import.","error":"TypeError: translator.query is not a function"},{"fix":"Set process.env.OPENAI_API_KEY to a valid key.","cause":"Missing or invalid OPENAI_API_KEY.","error":"OpenAI API error: 401 - Incorrect API key provided"},{"fix":"Check MYSQL_USER and MYSQL_PASSWORD, and ensure the user has access to the database.","cause":"Invalid MySQL credentials or insufficient privileges.","error":"Error: ER_ACCESS_DENIED: Access denied for user"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dannyusca/cyber-mysql-openai#readme","github":"https://github.com/dannyusca/cyber-mysql-openai","docs":null,"changelog":null,"pypi":null,"npm":"cyber-mysql-openai","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}