{"id":44112,"library":"vls-mysql","title":"VLS MySQL","description":"VLS MySQL is a lightweight TypeScript-native MySQL client for Node.js that provides a simple, promise-based API for executing queries and managing connections. Version 1.5.0 is the latest stable release, with periodic updates focused on reliability and compatibility. It differentiates itself by offering full TypeScript support out of the box, including generic query results, and a minimalistic design without unnecessary abstractions. Unlike heavier ORMs or legacy callback-based drivers, VLS MySQL focuses on direct SQL execution with type safety, making it suitable for projects that prefer raw SQL with typed returns.","status":"active","version":"1.5.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install vls-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add vls-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add vls-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying MySQL driver for Node.js","package":"mysql2","optional":false}],"imports":[{"note":"Module is ESM-only; CommonJS require will fail.","wrong":"const Mysql = require('vls-mysql')","symbol":"Mysql","correct":"import { Mysql } from 'vls-mysql'"},{"note":"QueryResult is a named export, not default.","wrong":"import QueryResult from 'vls-mysql'","symbol":"QueryResult","correct":"import { QueryResult } from 'vls-mysql'"},{"note":"All types are exported from the main entry point.","wrong":"import { MysqlConfig } from 'vls-mysql/config'","symbol":"MysqlConfig","correct":"import { MysqlConfig } from 'vls-mysql'"}],"quickstart":{"code":"import { Mysql } from 'vls-mysql';\n\nconst mysql = new Mysql({\n  host: process.env.DB_HOST ?? 'localhost',\n  port: Number(process.env.DB_PORT) ?? 3306,\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASSWORD ?? '',\n  database: process.env.DB_NAME ?? 'test'\n});\n\nasync function run() {\n  const result = await mysql.query<Array<{ id: number; name: string }>>('SELECT id, name FROM users');\n  console.log(result);\n  await mysql.close();\n}\nrun().catch(console.error);","lang":"typescript","description":"Shows how to create a Mysql connection, run a typed SELECT query, and close the connection."},"warnings":[{"fix":"Change `import Mysql from 'vls-mysql'` to `import { Mysql } from 'vls-mysql'`","message":"v2.0 changes the default export to named export 'Mysql'","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Replace `.query(sql, callback)` with `const result = await mysql.query(sql)`","message":"The `.query()` method's callback signature is deprecated; use async/await instead","severity":"deprecated","affected_versions":">=1.4.0"},{"fix":"Use multiple Mysql instances for pooling or upgrade to v2 where pool support is planned","message":"Connection pool not supported in v1.x; each Mysql instance creates a single connection","severity":"gotcha","affected_versions":">=1.0.0 <2.0.0"},{"fix":"Always specify the type parameter: `mysql.query<MyType[]>('SELECT ...')`","message":"Type generics must be explicitly provided; type inference from SQL strings is not supported","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.5.0':30 'abstract':66 'api':22 'base':21,74 'box':55 'callback':73 'callback-bas':72 'client':12 'compat':43 'connect':28 'design':63 'differenti':45 'direct':80 'driver':75 'execut':24,82 'focus':39,78 'full':49 'generic':57 'heavier':68 'includ':56 'javascript':98 'latest':33 'legaci':71 'lightweight':7 'make':86 'manag':27 'minimalist':62 'mysql':2,4,11,77 'nativ':10 'node.js':14 'offer':48 'orm':69 'period':37 'prefer':92 'project':90 'promis':20 'promise-bas':19 'provid':16 'queri':25,58 'raw':93 'releas':35 'reliabl':41 'result':59 'return':97 'safeti':85 'simpl':18 'sql':81,94 'stabl':34 'suitabl':88 'support':51 'type':84,96 'typescript':9,50,99 'typescript-n':8 'unlik':67 'unnecessari':65 'updat':38 'version':29 'vls':1,3,76 'without':64","created_at":"2026-06-05T17:03:02.674754+00:00","updated_at":"2026-06-05T17:03:02.674754+00:00","problems":[{"fix":"Change to `import { Mysql } from 'vls-mysql'`","cause":"Using default import instead of named import in v1.5.0","error":"TypeError: mysql.query is not a function"},{"fix":"Add \"type\": \"module\" to package.json or switch to import syntax","cause":"Missing 'type': 'module' in package.json or using require() in ESM project","error":"Cannot find module 'vls-mysql' or its corresponding type declarations."},{"fix":"Verify user, password, and host permissions in MySQL","cause":"Incorrect credentials or host not allowed to connect","error":"ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host'"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"vls-mysql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"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}}