Registry / testing / dbfixtures-mysql-driver

dbfixtures-mysql-driver

JSON →
library1.2.0jsnpmunverified

A MySQL driver for the dbfixtures package, providing an abstraction layer over the mysql package to facilitate handling database fixtures for testing. Current stable version is 1.2.0. It supports Node.js v8 or higher (with harmony_promise_finally flag for v8 and v9). It can be used standalone or with dbfixtures. Key differentiator: integrates seamlessly with the dbfixtures ecosystem, offering truncate, insertFixtures, and close methods while handling foreign key constraints. Not actively maintained (last release appears old).

npm install dbfixtures-mysql-driver
INSTALL
IMPORT
SIG · DBFIXTURES-MYSQL-D
D
dbfixtures-mysql-driver
testingjavascriptv1.2.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 fixturesMysqlDriver from 'dbfixtures-mysql-driver'
✗ const fixturesMysqlDriver = require('dbfixtures-mysql-driver').default
ESM import uses default export; CommonJS uses require without .default.
create
✓ import { create } from 'dbfixtures-mysql-driver'
✗ const create = require('dbfixtures-mysql-driver').create
Named export 'create' is available for ESM.
IDriver
✓ import type { IDriver } from 'dbfixtures-mysql-driver'
✗ import { IDriver } from 'dbfixtures-mysql-driver'
IDriver is a TypeScript type; import it as a type to avoid runtime errors.

Demonstrates how to create a MySQL driver, set it on dbfixtures, truncate tables, insert fixtures, and close the connection.

import dbfixtures from 'dbfixtures'; import fixturesMysqlDriver from 'dbfixtures-mysql-driver'; const mysqlConnectionInfo = { host: 'localhost', port: '3306', user: 'root', password: process.env.DB_PASSWORD ?? '' }; const fixtures = { 'users': [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' } ] }; async function runFixtures() { const driver = await fixturesMysqlDriver.create(mysqlConnectionInfo); dbfixtures.setDrivers(driver); await dbfixtures.truncateTables(['users']); await dbfixtures.insertFixtures(fixtures); console.log('Fixtures loaded'); await dbfixtures.closeDrivers(); } runFixtures();
Debug
Known issues
gotchaNode.js v8 and v9 require --harmony_promise_finally flag for this package (versions >=1.1.0).
fix
Use Node.js v10+ or run with --harmony_promise_finally flag.
affects: >=1.1.0
breakingVersion 1.0.x supported Node v7 only; 1.1.0 dropped v7 support.
fix
Upgrade to 1.1.0+ and use Node v8+.
affects: 1.0.x
gotchaPackage depends on mysql package, which is not a pure JavaScript driver and may require native compilation.
fix
Ensure build tools (e.g., gcc, python) are installed for native modules.
affects: >=0.0.0
deprecatedmysql package is considered deprecated; consider migrating to mysql2.
fix
Switch to dbfixtures-mysql2-driver if available or use mysql2 directly.
affects: >=1.2.0
gotchacreate() expects a ConnectionOptions object or DSN string; invalid options cause silent failures.
fix
Validate connection options before calling create().
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: fixturesMysqlDriver.create is not a function
Importing the module incorrectly and getting the default export as undefined.
fix
Use `const fixturesMysqlDriver = require('dbfixtures-mysql-driver')` (no .default) or ESM import.
Cannot find module 'mysql'
mysql package not installed or not found.
fix
Run `npm install mysql` as a dependency.
ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'
Invalid MySQL credentials provided.
fix
Check connection options (host, port, user, password) and ensure MySQL server is running.
Node.js flag --harmony_promise_finally is required
Using Node.js v8 or v9 without the flag.
fix
Upgrade to Node v10+ or run with --harmony_promise_finally flag.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver used for database operations
Agent activity
11 hits · last 30 days
node
10
Resources
dbfixtures-mysql-driver — npm install dbfixtures-mysql-driver · libregistry