Registry / database / anysql-mysql

anysql-mysql

JSON →
library0.2.1jsnpmunverified

MySQL implementation of the AnySQL API (v0.2.1). Provides a unified interface for MySQL database operations, abstracting over the mysql driver. This package is part of the AnySQL ecosystem aimed at database-agnostic querying. It is stable but minimally maintained, with no recent updates since 2017. Differentiator: it offers a consistent API if you already use AnySQL for other databases, but standalone use is limited. Release cadence: sporadic.

npm install anysql-mysql
INSTALL
IMPORT
SIG · ANYSQL-MYSQL
A
anysql-mysql
databasejavascriptv0.2.1
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.

default
import anySQL from 'anysql-mysql';
import {anySQL} from 'anysql-mysql';
Default import is the main entry point; named imports not provided.
default (require)
const anySQL = require('anysql-mysql');
const {anySQL} = require('anysql-mysql');
CommonJS require returns the default export as an object.
config object
const db = anySQL({ host: 'localhost', user: 'root', password: 'pass', database: 'test' });
const db = anySQL('host=localhost user=root');
Configuration must be an object, not a connection string.

Shows creating a connection and running queries with parameterized inputs.

import anySQL from 'anysql-mysql'; const db = anySQL({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? 'password', database: process.env.DB_NAME ?? 'test' }); async function init() { await db.query('CREATE TABLE IF NOT EXISTS users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))'); await db.query('INSERT INTO users (name) VALUES (?)', ['Alice']); const results = await db.query('SELECT * FROM users'); console.log(results); } init().catch(console.error);
Debug
Known issues
gotchaanysql-mysql does not support connection pooling. Each call creates a new connection.
fix
Use a separate connection pool or handle connections manually.
affects: >=0.0.0
gotchaThe API is synchronous-style but uses Promises under the hood. Callbacks not supported.
fix
Use async/await or .then().
affects: >=0.0.0
deprecatedThe package uses the deprecated 'mysql' driver which has known authentication issues with MySQL 8.0+.
fix
Use 'mysql2' driver or switch to a more modern library like 'mysql2/promise'.
affects: >=0.0.0
gotchaNo TypeScript type definitions are included; using with TypeScript requires custom types.
fix
Install @types/anysql-mysql if available, or create a declaration file.
affects: >=0.0.0
Errors
Common errors & fixes
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
MySQL 8.0 uses caching_sha2_password by default; the 'mysql' driver used by anysql-mysql does not support it.
fix
Alter MySQL user to use mysql_native_password: ALTER USER 'user'@'host' IDENTIFIED WITH mysql_native_password BY 'password';
Error: Cannot find module 'anysql'
Missing peer dependency 'anysql' which is required at runtime.
fix
Install both packages: npm install anysql anysql-mysql
TypeError: db.query is not a function
The import was not correctly obtained; likely used a named import or misconfigured the connection object.
fix
Use default import: import anySQL from 'anysql-mysql'; const db = anySQL({...});
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver for Node.js
anysqlrequiredCore AnySQL API, defines the interface this package implements
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
anysql-mysql — npm install anysql-mysql · libregistry