Registry / database / vls-mysql

vls-mysql

JSON →
library1.5.0jsnpmunverified

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.

npm install vls-mysql
INSTALL
IMPORT
SIG · VLS-MYSQL
V
vls-mysql
databasejavascriptv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Mysql
import { Mysql } from 'vls-mysql'
const Mysql = require('vls-mysql')
Module is ESM-only; CommonJS require will fail.
QueryResult
import { QueryResult } from 'vls-mysql'
import QueryResult from 'vls-mysql'
QueryResult is a named export, not default.
MysqlConfig
import { MysqlConfig } from 'vls-mysql'
import { MysqlConfig } from 'vls-mysql/config'
All types are exported from the main entry point.

Shows how to create a Mysql connection, run a typed SELECT query, and close the connection.

import { Mysql } from 'vls-mysql'; const mysql = new Mysql({ host: process.env.DB_HOST ?? 'localhost', port: Number(process.env.DB_PORT) ?? 3306, user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test' }); async function run() { const result = await mysql.query<Array<{ id: number; name: string }>>('SELECT id, name FROM users'); console.log(result); await mysql.close(); } run().catch(console.error);
Debug
Known issues
breakingv2.0 changes the default export to named export 'Mysql'
fix
Change `import Mysql from 'vls-mysql'` to `import { Mysql } from 'vls-mysql'`
affects: >=2.0.0
deprecatedThe `.query()` method's callback signature is deprecated; use async/await instead
fix
Replace `.query(sql, callback)` with `const result = await mysql.query(sql)`
affects: >=1.4.0
gotchaConnection pool not supported in v1.x; each Mysql instance creates a single connection
fix
Use multiple Mysql instances for pooling or upgrade to v2 where pool support is planned
affects: >=1.0.0 <2.0.0
gotchaType generics must be explicitly provided; type inference from SQL strings is not supported
fix
Always specify the type parameter: `mysql.query<MyType[]>('SELECT ...')`
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: mysql.query is not a function
Using default import instead of named import in v1.5.0
fix
Change to `import { Mysql } from 'vls-mysql'`
Cannot find module 'vls-mysql' or its corresponding type declarations.
Missing 'type': 'module' in package.json or using require() in ESM project
fix
Add "type": "module" to package.json or switch to import syntax
ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host'
Incorrect credentials or host not allowed to connect
fix
Verify user, password, and host permissions in MySQL
Upgrade
Version history
1.5.0latest on npm
Audit
Dependencies
mysql2requiredUnderlying MySQL driver for Node.js
Agent activity
20 hits · last 30 days
node
14
Meta
1
OpenAI (training)
1
Resources
vls-mysql — npm install vls-mysql · libregistry