Registry / database / webiny-mysql-connection

webiny-mysql-connection

JSON →
library1.9.0jsnpmunverified

A MySQL connection handler for Webiny, version 1.9.0, maintained as part of the Webiny.js monorepo. Provides a simple wrapper around mysql2 with connection pooling and promise-based interface. Lightweight and focused on Node.js environments.

npm install webiny-mysql-connection
INSTALL
IMPORT
SIG · WEBINY-MYSQL-CONNE
W
webiny-mysql-connection
databasejavascriptv1.9.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.

default
import createConnection from 'webiny-mysql-connection'
const createConnection = require('webiny-mysql-connection')
Default export only; ESM or CommonJS via default interop.
createConnection
import createConnection from 'webiny-mysql-connection'
import { createConnection } from 'webiny-mysql-connection'
Named import is incorrect; use default import.
Connection
import type { Connection } from 'webiny-mysql-connection'
import { Connection } from 'webiny-mysql-connection'
Type import only; Connection is a TypeScript interface, not a constructor.

Shows creating a connection and executing a simple query with TypeScript types.

import createConnection from 'webiny-mysql-connection'; import type { Connection } from 'webiny-mysql-connection'; async function main() { const connection: Connection = await createConnection({ host: process.env.MYSQL_HOST ?? 'localhost', port: Number(process.env.MYSQL_PORT ?? 3306), user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test' }); const [rows] = await connection.execute('SELECT 1+1 AS result'); console.log(rows); await connection.end(); } main().catch(console.error);
Debug
Known issues
gotchaThe package only exports a default function; named exports are not present.
fix
Use default import: import createConnection from 'webiny-mysql-connection'
affects: >=1.0.0
deprecatedOlder versions may use callbacks; migrate to async/await.
fix
Use promise-based API with async/await.
affects: >=1.0.0 <1.5.0
gotchaConnection parameters require numeric port; passing string may cause unexpected behavior.
fix
Ensure port is a number, e.g., port: Number(process.env.MYSQL_PORT)
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'webiny-mysql-connection'
Missing dependency installation
fix
Run 'npm install webiny-mysql-connection' or 'yarn add webiny-mysql-connection'
TypeError: createConnection is not a function
Wrong import style (named import instead of default)
fix
Use 'import createConnection from 'webiny-mysql-connection';'
Error: Cannot read properties of undefined (reading 'execute')
Connection object not resolved correctly, possibly due to incorrect import or missing await
fix
Ensure you await the createConnection call and use default import.
Upgrade
Version history
1.9.0latest on npm
Audit
Dependencies
mysql2requiredprovides MySQL client with prepared statements and promise support
Agent activity
25 hits · last 30 days
node
22
Meta
1
OpenAI (training)
1
Resources
webiny-mysql-connection — npm install webiny-mysql-connection · libregistry